views:

1256

answers:

5

How can the memory leak in Eclipse RCP applications detected?

+1  A: 

You need some kind of profiling tool.

There is a Memory Analyzer project at eclipse (wiki, blog).

Also, it looks like TPTP also does profiling.

Andrew Niefer
A: 

If you're on windows the simplest way is simply to monitor the e.g. eclipse.exe process in Task Manager while using the tool. If your RCP executable has a different name then this is what you'll need to monitor. On Unix you can use an analogous tool (proc maybe?).

Perform the most intensive tasks available (or if you suspect certain functions cause the problem, use those). IF the amount of memory used by eclipse.exe rises does not eventually decrease after your intensive tasks have completed then you likely have a leak. This will eventually cause an out of memory error.

You can accelerate an out of memory error by reducing the amount of memory available to the application via the "-Xmx" setting in eclipse.ini (or .ini). E.g. -Xmx256m means a maximum 256 megabytes is available. Obviously this setting still needs to be sufficient to run your app, but a lower setting will force more frequent garbage collection and make leaks more apparent.

Bryan Solan
+1  A: 

You need a memory profiler (as others have mentioned.) Once you have a good tool, you can find the problems rather easily.

We use: http://www.yourkit.com/

for our testing, it works very well, has floating licenses so devs can use it locally on their machines.

Basically, you take a snapshot of the actions that you are taking and then look at the items that were allocated and not released.

Edit: I forgot to add, this tool integrates right into eclipse.

GreenKiwi
+1  A: 
Kire Haglin
A: 

The simplest solution comes with Java JDK: Java VisualVM.

It's located in the bin directory (jvisualvm.exe under Windows) since JDK 6 update 7.

Also includes a memory profiler, a heap walker and an Eclipse integration.

https://visualvm.dev.java.net/images/getstarted/vvm-anagram-profiler.png (too bad, I'm not allowed to use image tags)

See https://visualvm.dev.java.net/

Meinersbur