Ticket #2808: ShrinkingGCHack.diff
File ShrinkingGCHack.diff, 2.5 KB (added by , 10 years ago) |
---|
-
source/gui/GUIManager.cpp
379 379 380 380 // We share the script runtime with everything else that runs in the same thread. 381 381 // This call makes sure we trigger GC regularly even if the simulation is not running. 382 m_ScriptInterface->MaybeIncrementalRuntimeGC(1.0f);383 382 383 //m_ScriptInterface->MaybeIncrementalRuntimeGC(1.0f); 384 385 m_ScriptInterface->ShrinkingGC(); 386 384 387 // Save an immutable copy so iterators aren't invalidated by tick handlers 385 388 PageStackType pageStack = m_PageStack; 386 389 -
source/scriptinterface/ScriptInterface.cpp
230 231 } 231 232 } 232 233 234 void ShrinkingGC() 235 { 236 int gcBytes = JS_GetGCParameter(m_rt, JSGC_BYTES); 237 int gcUnusedChunks = JS_GetGCParameter(m_rt, JSGC_UNUSED_CHUNKS); 238 int gcTotalChunks = JS_GetGCParameter(m_rt, JSGC_TOTAL_CHUNKS); 239 std::cout << "gcBytes: " << gcBytes << std::endl; // debugging 240 std::cout << "gcUnusedChunks: " << gcUnusedChunks << std::endl; // debugging 241 std::cout << "gcTotalChunks: " << gcTotalChunks << std::endl; // debugging 242 243 std::cout << "Calling a shrinking GC!" << std::endl; 244 245 JS::PrepareForFullGC(m_rt); 246 JS::ShrinkingGC(m_rt, JS::gcreason::REFRESH_FRAME); 247 248 std::cout << "gcBytes: " << gcBytes << std::endl; // debugging 249 std::cout << "gcUnusedChunks: " << gcUnusedChunks << std::endl; // debugging 250 std::cout << "gcTotalChunks: " << gcTotalChunks << std::endl; // debugging 251 } 252 253 233 254 void RegisterContext(JSContext* cx) 234 255 { 235 256 m_Contexts.push_back(cx); … … 1424 1445 m->m_runtime->MaybeIncrementalGC(delay); 1425 1446 } 1426 1447 1448 void ScriptInterface::ShrinkingGC() 1449 { 1450 m->m_runtime->ShrinkingGC(); 1451 } 1452 1427 1453 void ScriptInterface::MaybeGC() 1428 1454 { 1429 1455 JS_MaybeGC(m->m_cx); -
source/scriptinterface/ScriptInterface.h
363 363 */ 364 364 void MaybeIncrementalRuntimeGC(double delay); 365 365 366 void ShrinkingGC(); 367 366 368 /** 367 369 * Triggers a full non-incremental garbage collection immediately. That should only be required in special cases and normally 368 370 * you should try to use MaybeIncrementalRuntimeGC instead.