belgattitude / soluble-japha

PHP Java integration
https://belgattitude.github.io/soluble-japha/
MIT License
69 stars 15 forks source link

How to destruct an object? #45

Closed marcospassos closed 7 years ago

marcospassos commented 7 years ago

Hi @belgattitude!

Is there any way to destruct an object on the Java side to free memory?

belgattitude commented 7 years ago

Are you sure it's not already the case ?

The code is not very clear about it... I see a JavaProxy::destruct() method that will unref the javaobject on the JVM side. So basically unset($javaObject) should trigger `destruct()that will delegate a call to the bridgeClient::unref($object_id)`.

I'm not 100% sure, but looks the phpjavabridge already handles that: explicitly by calling unset or implicitly when objects are garbage collected on the PHP side. One exception is when the script ends, the protocol will be closed. So I suppose the bridge server handles that when closing the connection.

Should work like that, otherwise I would have seen a ever growing memory on my bridge.

Feel free to search on that, it can be helpful