| 338 | |
| 339 | if constexpr (!snap::kIsAppstoreBuild || !snap::isIos()) { |
| 340 | // JSGetMemoryUsageStatistics() is currently a private symbol, so we use it |
| 341 | // only on Android/Desktop or non production iOS. |
| 342 | |
| 343 | if (JSGetMemoryUsageStatistics) { |
| 344 | auto memoryUsageJs = JSGetMemoryUsageStatistics(_globalContext); |
| 345 | |
| 346 | if (!memoryUsageJs) { |
| 347 | return out; |
| 348 | } |
| 349 | |
| 350 | Valdi::JSExceptionTracker exceptionTracker(*this); |
| 351 | auto memoryUsage = Valdi::jsValueToValue( |
| 352 | *this, |
| 353 | toValdiJSValue(JSCoreRef(memoryUsageJs, JSValueGetType(_globalContext, memoryUsageJs))), |
| 354 | Valdi::ReferenceInfoBuilder(), |
| 355 | exceptionTracker); |
| 356 | |
| 357 | exceptionTracker.clearError(); |
| 358 | |
| 359 | out.memoryUsageBytes = static_cast<size_t>(memoryUsage.getMapValue("heapCapacity").toLong()); |
| 360 | out.objectsCount = static_cast<size_t>(memoryUsage.getMapValue("objectCount").toLong()); |
| 361 | } |
| 362 | } |
nothing calls this directly
no test coverage detected