Trouble with Callbacks.

Started by Risa123, April 01, 2018, 15:16:38

Previous topic - Next topic

Risa123

I done this and all leaks just magicaly disapeared....

Risa123

I done this and every leak just magically disapeared...

Risa123

Sorry for double post i dont realized that this thread now have two pages.

spasi

Quote from: Risa123 on April 02, 2018, 08:42:51I done this and all leaks just magicaly disapeared....

Yes, this was expected as I explained above. More information:

The debug allocator registers a JVM shutdown hook that is called when the process exists, for any reason. When the hook runs, it doesn't know whether the process is exiting normally or abnormally, so it always reports potential memory leaks. This means that when your application exists early with an unhandled exception, before running the usual cleanup code, a lot of false positive memory leaks will be reported.

Something you can do to avoid this, and also a good practice in general, is to use try/finally blocks to ensure that proper cleanup is always performed, even in the presence of unexpected exceptions.