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