|
Project Information
Members
Featured
Wiki pages
Links
|
This garbage collector uses a mark-sweep algorithm . Unlike BDW conservative garbage collector , it doesn't guess the pointer . So you should link the objects (memory block) manually by call gc_link . Namely , you should tell the collector that a memory block's life time depends on the correlative one's . On the other hand, you should give the scope of temporary variable on the stack manually. It will be easy if you call gc_enter at the first line of the function, and call gc_leave at the last line. btw, you don't need to call gc_enter / gc_leave every time. For example, you can only call gc_enter before your main loop and call gc_leave after the main loop returned. (It may waste some memory, but it works.) If you have done those correctly , gc_collect will be able to determine which memory block won't be accessed any longer, and then free them. ps. Another description here , if you can read Chinese. |