mmomtchev/swig

Provide memory statistics to the garbage collector

Opened this issue · 0 comments

Currently, when handling a SWIG-proxied C/C++ object, the GC sees only the tip of the iceberg - namely the JavaScript proxy object - which is usually in the 60 to 80 bytes range.

When the GC decides to free this object, all allocated memory will be freed - so there is no leak.

However the GC may be much more reluctant to actually perform a garbage pass, since these objects are considered too small.

This can lead to out-of-memory errors If the program allocates large amounts of such objects.

This is a generic problem with automatic memory management languages in SWIG that is not specific to JavaScript.