Using the Java heap to allocate C++ objects does two things, (1) re-establishes the JVM's heap limits even for SWIG wrapped code and (2) puts more pressure on the garbage collector to finalize objects (and thus free the SWIG objects that are unreachable)
This technique was presented at Usenix 2007
This patch includes an approximately 70 line chunk of code that, if included in a SWIG interface file, will move all SWIG C++ objects into the Java heap. If this proves popular or effective in practice, the community might consider making it an automatically generated option for Java builds.
Log in to post a comment.