How to find memory leaks in java?
And preventive methods advisable?

Recommended Answers

All 2 Replies

Its quite hard to make memory leaks in java, having said that I've done it by leaving active connections open.

The try { } catch{} {finally} blocks help in preventing such a case from arrising.

The try block allows the code to throw exceptions - in the exception were plausable any variables that were created within the try should be set to NULL to allow the garbage collector to release the memory back to the JVM.

The finally block allows executes no matter what happend in the try block.

Hope this helps.

As acid burn said, java does not suffer from memory leaks the same as a procedural based language (like C0. The JVM 'disposes' memory leaks as it is shut down.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.