Re: Memory leaks when embedding and using JavaXPCOM
David Pérez <[email protected]> Wed, 15 Jul 2009 06:20:46 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <5985470a-dcbf-4e15-a5a0-6ff9e63d16e7@s31g2000yqs.googlegroups.com> |
Hi, I have made some improvements in JavaXPCOM. They are related to a more efficient way of disposing native resources from Java proxies when they are garbage collected. I've been following the guidelines of this nice article: http://java.sun.com/developer/technicalArticles/javase/finalization How can I contribute them back to the community? Should I open a bug and attach a patch ? If I do so, will the change be merged with trunk, after being evaluated? On 14 Jul., 09:50, David P=E9rez <[email protected]> wrote: > Hi Benjamin, > > First of all, thanks for your valuable answer. > > On 1 Jul., 16:33, Benjamin Smedberg <[email protected]> wrote: > > > On 7/1/09 5:47 AM, David P rez wrote: > > > > We ve made a simple XULRunner app, coded in Java. > > > We ve observed that it has huge memory leaks. > > > Rewriting the same app in Javascript, we observe no leaks. > > > That's certainly possible. JavaXPCOM doesn't have an owner and I may > > consider removing it in the next release if we can't find an owner. > > JavaXPCOM, even when leaky, is very useful, so I wouldn't drop it in > the next release. > > > > > > So, we suspect there is some problem with JavaXPCOM. =A0Maybe the > > > problem is related with the cycle collector. > > >https://developer.mozilla.org/En/Interfacing_with_the_XPCOM_cycle_col.= .. > > > Is your code creating object cycles. In most cases if you are in contro= l of > > the code you can manually avoid object cycles by nulling references when > > they are no longer needed. I suspect adding cycle-collection to the > > JavaXPCOM interface would be very difficult, because it would require > > knowing all the object edges through the Java GC heap. > > I have made simply an app that loads an URL in a browser, waits > through events till the page is loaded, and emulates mouse clicks in > certains part of the page. =A0In Java code I need to make XPCOM calls to > objects. =A0For reacting to events (page loaded), I need to create Java > objects that implements certain nsIXXXX interface. > > Maybe the cycling collector isn't the real problem, it's just a > supposition. > > I have tried to apply this patch and the memory leaks have improved a > lot.https://bugzilla.mozilla.org/show_bug.cgi?id=3D501930 > > > --BDS