Help

#120 Jacob memory leak

Hi guys,
I have a memory leak in Jacob (not Java memory, but JVM process memory) when I'm parsing data returned by Excel (all that data I send from Excel to Java are accumulated in java.exe RAM - I've checked that by memory dump analysis).
I've tried jdk1.6.0_38, jdk1.7.0_51 (64 bit) with the same result.
Also I've followed recommendations from here: http://stackoverflow.com/questions/980483/jacob-doesnt-release-the-objects-properly
with no result.
Here is the way I use Jacob:

Please post a full application that exhibits the bug, so that we could try it in our environments. Without that it's hard to tell what's causing the memory growth. You may possibly accumulate the results in other part of your code.

It would be best to use only WScripting objects or those that can be found on any Windows. But for me Excel is ok.

I see... Thanks for your reply.
During my testing I cleaned up the results just after interaction with Jacob and still saw the leak.
I will try to extract this part from application, but it's not very easy.

That's weird. After removing Variant.finalize method memory usage reduces several times. And it's not a matter of safeRelease called there, because any finalize method, even as simple as cFin+=1, brings the memory leak back.

Seems like a Java bug. Could we workaround this? By removing finalize method at all? ComThread.release calls safeRelease anyway. Dima, does this work for you?

I don't understand what do you mean by 'finalize method' - I do not call it, at least directly.

You can modify Jacob source as suggested in this comment. If you want to use original Jacob, without modification, use this comment instead. The theory is described in the article, linked from the second comment.

Thanks, Jarek.
Changing the Jacob itself is quite a big task for me, so I've decided to try the second option you've provided.
I put 1000 cycles instead of 100 just to be on the safe side. Result is negative - the leak is still exist. I've attached memory consumption screenshot (25% CPU usage was for GC 1000 executions).
NB I set -Xms2048m -Xmx2048m options in my Java, but Java.exe process go beyond that.

Also I want to notice that the leak is not in the heap memory, max heap size = 2,009,792 kbytes as you could see on the screenshot, but commited virtual memory is 2,576,276 kbytes (it could reach 12 GB and more, causing OOM error).

Dima, our private correspondence reveals that you use an old version of Jacob, 1.17-M2. You should always try using the newest version before submitting a bug report. If that's not possible, you should state which version you are using. Please test on 1.18-M1. Is it better?

Thanks for doing the testing, Dima. Now that I kind of fixed the problem in my example and this trick doesn't work for you - the only possibility to move on is that you post a complete code to reproduce the issue.