To control lifetime explicitly you could
Cast it to IJvmProxy and
((IJvmProxy)javaInstance).JvmHandle.Dispose()
I'm open to discuss explicit disposal problem.
I had that approach in very early version already. It seemed to me
that GC is better approach for general use cases.
IDisposable seems to me like overkill. Few reasons
- GC will behave different to object which implement IDisposable
- Dispose() method doesn't look nice in intellisense of each proxy (if
we make it public) and may clash with Java side API.
- Consider ClrProxy on JVM/Java side too. We could add
java.io.Closeable (or something) to it.
I don't believe most people will manage the handles explicitly. It is
quite difficult to realize how many proxies are created all the time.
jni4net usage feels very similar to normal use of the OOP and people
don't notice that they deal with proxies most of the time.
People who really care about performance/leaks like yourself should be
able to address it. I propose we make it easier.
- by adding static Bridge.Dispose(IJvmProxy obj)
- we may allow you to register callback for proxy instantiation, so
you could collect all proxies and dispose them as necessary.
Hey, other people, please share your thoughts too :-)
Cheers
Pavel
> --
> You received this message because you are subscribed to jni...@googlegroups.com
> http://groups.google.com/group/jni4net?hl=en-GB?hl=en-GB
> http://jni4net.sf.net/
>