Hello Guest

Trouble with Callbacks.

  • 18 Replies
  • 10403 Views
Re: Trouble with Callbacks.
« Reply #15 on: April 02, 2018, 08:42:51 »
I done this and all leaks just magicaly disapeared....

Re: Trouble with Callbacks.
« Reply #16 on: April 02, 2018, 08:43:37 »
I done this and every leak just magically disapeared...

Re: Trouble with Callbacks.
« Reply #17 on: April 02, 2018, 08:44:52 »
Sorry for double post i dont realized that this thread now have two pages.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Trouble with Callbacks.
« Reply #18 on: April 02, 2018, 09:30:34 »
I 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.