JVM Shutdown Hooks

Hi all,

I have noticed that as my project grew bigger, it became more and and more dependant on native libraries. Ode, lwjgl are the main ones…And frankly, i dont trust em…

A good way, IMO, to solve the problem would be to create a shutdown hook on the jvm that when it closes down, it envokes “cleanup”. Thats even with a force shutdown, cleanup would occur.

I haven’t really thought about Thread sync issues, nor about design implementations and how the architecture would be affected…etc.

Id like to hear your thoughts about this…


Just so I’m clear, are you afraid that when you exit your application that those native libraries are not being cleaned up from memory?

yer, the allocations that they create might be left behind…

I know that they are open source and when a leak is found, it is reported immediately and fixed pronto. But there is still that voice in the back of my head goin "did they clean up properly?"

Or is the memory allocations made by the native libs during a java application included in the java memory allocation and hence are cleaned up when the system exits?