| 306 | JSSynchronousGarbageCollectForDebugging(_globalContext); |
| 307 | #endif |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | Valdi::JavaScriptContextMemoryStatistics JavaScriptCoreContext::dumpMemoryStatistics() { |
| 312 | if (s_dumpMemoryStatisticsOverride) { |
| 313 | return s_dumpMemoryStatisticsOverride(_globalContext); |
| 314 | } |
| 315 | |
| 316 | Valdi::JavaScriptContextMemoryStatistics out; |
| 317 | |
| 318 | if constexpr (!snap::kIsAppstoreBuild || !snap::isIos()) { |
| 319 | // JSGetMemoryUsageStatistics() is currently a private symbol, so we use it |
| 320 | // only on Android/Desktop or non production iOS. |
| 321 | |
| 322 | if (JSGetMemoryUsageStatistics) { |
| 323 | auto memoryUsageJs = JSGetMemoryUsageStatistics(_globalContext); |
| 324 | |
| 325 | if (!memoryUsageJs) { |
| 326 | return out; |
| 327 | } |
| 328 | |
| 329 | Valdi::JSExceptionTracker exceptionTracker(*this); |
| 330 | auto memoryUsage = Valdi::jsValueToValue( |
| 331 | *this, |
| 332 | toValdiJSValue(JSCoreRef(memoryUsageJs, JSValueGetType(_globalContext, memoryUsageJs))), |
| 333 | Valdi::ReferenceInfoBuilder(), |
| 334 | exceptionTracker); |
| 335 | |
| 336 | exceptionTracker.clearError(); |
nothing calls this directly
no test coverage detected