20,741
edits
m (→Problem) |
m (→bottleneck()) |
||
| Line 282: | Line 282: | ||
= bottleneck() = | = bottleneck() = | ||
Whenever new memory from one of the global pools is being requested via naGC_get(), naCheckBottleneck() will also be invoked: | |||
https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/gc.c#line121 | |||
<syntaxhighlight lang="C"> | |||
void naCheckBottleneck() | |||
{ | |||
if(globals->bottleneck) { LOCK(); bottleneck(); UNLOCK(); } | |||
} | |||
</syntaxhighlight> | |||
This checks if globals->bottleneck is true, and if it is, it makes sure that the bottleneck() function is only invoked after acquiring a lock. | |||
https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/gc.c#line99 | https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/gc.c#line99 | ||
<syntaxhighlight lang="C"> | <syntaxhighlight lang="C"> | ||
// Must be called with the main lock. Engages the "bottleneck", where | // Must be called with the main lock. Engages the "bottleneck", where | ||
| Line 309: | Line 321: | ||
The actual garbage collection takes place in [https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/gc.c#line114 line 114] where dead objects from the memory pool are freed, and the garbageCollect() function is called if globals.needGC is true. | The actual garbage collection takes place in [https://gitorious.org/fg/simgear/blobs/next/simgear/nasal/gc.c#line114 line 114] where dead objects from the memory pool are freed, and the garbageCollect() function is called if globals.needGC is true. | ||
= garbageCollect() = | = garbageCollect() = | ||