From: Panayotis K. <pan...@pa...> - 2010-03-23 15:28:14
|
I am wondering for a long time, how to have weak references under xmlvm. You know that already, but just for reference I say that weak references are sometimes needed, to avoid cyclic dependencies. An example with those are with delegates, which need to have a weak reference to the actual object. If they simply have a strong reference, then there will be a cycle and everything will stay onto memory. Thus I have created a patch which actually deals with the problem. First of all it gives access to the retain/release mechanism, just in case, although I am not sure that this is something that should be exposed in Java, but anyway. It also gives access to dealloc, which is a vital location to clean up weak references. And at the end it provides an utility object, which will perform the actual weak binding between the two objects, but which will also avoid cyclic dependencies. This could be mostly used for delegates, but it can also be used for any other case someone wants to break cyclic dependencies in Java. What do you think? PS: I am not sending the patch right now, only because it depends on my previous memory management approach. I could, though, send the "unofficially" the patch even in this list to have a look and gather opinions. |