Java memory Leaks can occur in the following ways:
The following code can be used to do this in the application:
- Saving an Object reference in to class level collection and forgetting to remove it at the proper time.
- Not Closing the JDBC Statement/ResultSets in a finally block.
- In native code, the Programmer forgetting to free a memory block.
The following code can be used to do this in the application:
System.out.println(“Java memory in use = “ + Runtime.getRuntime().totalMemory() – Runtime.getRuntime().freeMemory() );
No comments:
Post a Comment