In several of our use cases we pass the c++ half of the director down into a c++ framework, where the life cycle off the passed object (a smart pointer) is difficult to model. In this case we simply want the "java half" to stay alive as long as the c++ half is alive, cMemOwned= true, or whatever. I think that is what was being suggested, but haven't had time to investigate and implement. For now we just hold the java object ref for "longer than necessary" which is actually wrong since in some hard to model cases it won't be long enough. But we're in a beta now.
cMemOwned= true will not cause SWIG to keep the Java half alive, it will just cause the Java finalize() to deallocate the C++ object or not, afaict. It has nothing to do with the life-time of the Java objects, which is only related to the Java GC. And a C++ director without its Java half is useless as the whole idea is to invoke Java code.
In your first example from stack overflow, the MyHeldBase instance will be marked for garbage collection as soon as the hold() method returns as no one is keeping a reference. Whether its finalize will also deallocate your C++ object (cMemOwned) has no influence on whether your Java implementation of doSomething is still available - generally it will not as the corresponding object just got garbage collected. If it worked at any point, then only because you called doSomething on the director before the Java GC ran.
That all seems over-engineered for a problem that would vanish if proxy classes would keep references to directors they receive.
So you could try doing something with a separate case for those using a class member Collection, and a static method addOwned() (and perhaps rmOwned()). And BTW, our initial approach was to tell our alpha users to just hold references in their own code, before we figured out some of these approaches.
The proxy jni classes do hold a reference (as a long), which is how swig does everything. I think changing cMemOwned essentially does what you want. But... I haven't looked at this in some weeks, and this is all hard to keep in your head for 30 minutes. Maybe your suggestion is correct. Perhaps you can mock up a small example demonstrating. Hopefully some "director experts" will chime in.