From: William S F. <ws...@fu...> - 2012-03-27 22:44:14
|
On 01/02/12 18:16, Russell Johnston wrote: > I have a C++ library that is called by Java through a SWIG-based > interface. On the Java side, I build up a structure containing > pointers to arrays of other structures, using the default struct > interface andcarrays.i's %array_class. > > Because Java's garbage collector is not aware of the members of the > top-level struct, the array is sometimes freed, whereon its finalizer > delete[]s its backing memory. I need a way around this, preferably > without duplicating the struct in Java, since it's rather large. > > A minimal example looks like this (although it probably won't trigger > the bug since it doesn't do much): The following might help: http://www.swig.org/Doc2.0/Java.html#Java_memory_management_objects as well as the previous section. William |