RE: Memory Problems with String
Ander Ruiz <[email protected]> Sat, 9 Sep 2006 22:07:14 +0200 (CEST)
| Newsgroups | gmane.comp.mozilla.jrex |
|---|---|
| Message-ID | <[email protected]> |
There is a known problem with ProgressEvents that
create a memory leak problem. As far as I know the
problem is solved in the CVS but not in the binary
files. You can disable ProgressEvents in the
JRexEventManager:
private JRexEventHandler getHandler(int eventType){
switch(eventType){
case JRexEventType.WINDOW_EVENT:
return wEvtHandler;
case JRexEventType.HISTORY_EVENT:
//return hEvtHandler;
return null;
case JRexEventType.PROGRESS_EVENT:
//return pEvtHandler;
return null;
case JRexEventType.CONTEXT_MENU_EVENT:
//return cEvtHandler;
return null;
case JRexEventType.TOOL_TIP_EVENT:
return ttEvtHandler;
case JRexEventType.OBSERVER_EVENT:
return obEvtHandler;
case JRexEventType.URICONTENT_EVENT:
//return ucEvtHandler;
return null;
default:
if(JRexL.on)JRexL.log(className,"**** UNKNOWN
eventType<"+eventType+"> ****");
};
return null;
}
Ander
--- Ken <[email protected]> escribió:
> Hello all,
>
> I notice a large number of string objects are
> accumulated when JRex navigating
> to different pages. My profiling information points
> to xpcomInitImpl$1.run()
> as the source of the allocations.
>
> The uncollected strings seem to be http headers
> information. They have values
> including, "Content-Length", "text/html", and etc.
>
> Has anyone encounters this similar problem?
>
> Could it possible there are caching options I need
> to set in JRex? Or
> something I am not using correctly in JRex?
>
> I used one of the sample testers in the existing
> postings. It is included at
> the end of this post. After each page is loaded,
> the number of string objects
> will increase from xpcomInitImpl$1.run() without
> garbage collected, until the
> tester is terminated.
>
> Thanks for taking your times reading my questions.
> Please let me know if
> there is more information I can provide.
>
> Thanks,
> Ken
>
>
>
> package test;
>
> import org.mozilla.jrex.JRexFactory;
> import org.mozilla.jrex.event.window.WindowListener;
>
> import org.mozilla.jrex.navigation.WebNavigation;
> import
> org.mozilla.jrex.navigation.WebNavigationConstants;
> import org.mozilla.jrex.window.JRexWindowManager;
>
> import java.io.BufferedReader;
> import java.io.InputStreamReader;
> import java.util.ArrayList;
> import javax.swing.JFrame;
> import javax.swing.JPanel;
>
> public class JRexTest implements WindowListener {
>
> int _nativePeerId = -1;
>
> public static void main(String args[]) throws
> Exception {
> new JRexTest().runMe();
> }
>
> public void runMe() throws Exception {
> boolean enableDom = true;
> boolean loadDocument = true;
> JFrame f = new JFrame();
> JPanel p = new JPanel();
> f.getContentPane().add(p);
> p.setPreferredSize(new
> java.awt.Dimension(500, 300));
> p.setSize(new java.awt.Dimension(500,
> 300));
> p.setMinimumSize(new
> java.awt.Dimension(500, 300));
> f.setVisible(true);
>
> // TODO: Insert your GRE path
> System.setProperty("jrex.gre.path",
> "C:\\jrex\\gre");
> System.setProperty("jrex.dom.enable",
> String.valueOf(enableDom));
> JRexFactory.getInstance().startEngine();
>
> JRexWindowManager winManager =
> (JRexWindowManager)
>
> JRexFactory.getInstance().getImplInstance
> (JRexFactory.WINDOW_MANAGER);
>
>
> winManager.create(JRexWindowManager.TAB_MODE);
> winManager.addJRexWindowListener(this);
> winManager.init(p);
>
> waitForNativePeerId();
> winManager.removeJRexWindowListener();
>
> org.mozilla.jrex.ui.JRexCanvas browser =
> winManager.getBrowser(_nativePeerId);
>
> WebNavigation navigation =
> browser.getNavigator();
> ArrayList<String> startUris = new
> ArrayList<String>();
>
> // TODO: Insert your own URLs
>
> startUris.add("C:\\jrex\\testpages\\test1.htm");
>
> startUris.add("C:\\jrex\\testpages\\test2.htm");
>
> startUris.add("C:\\jrex\\testpages\\test3.htm");
>
> String referrer = null;
> int i = 1;
> boolean done = false;
> BufferedReader in = new BufferedReader(new
> InputStreamReader
> (System.in));
>
> while (!done)
> {
> System.out.println("0. Exit");
> System.out.println("1. Load pages
> again");
> int option = 2;
>
> try {
> option =
> Integer.parseInt(in.readLine());
> } catch (Exception e) {
> }
>
> switch (option)
> {
> case 0:
> done = true;
> break;
>
> case 1:
> for (int j = 1; j <= 10; j++) {
>
> for (String uri :
> startUris) {
> System.err.println("");
>
>
> System.err.println("------------------------------
> ------------------------i=" + (i++));
> System.err.println("");
>
> navigation.loadURI(uri,
>
>
> WebNavigationConstants.LOAD_FLAGS_NONE,
> referrer, null, null);
>
> try {
>
> System.err.println("sleeping");
> System.gc();
> Thread.sleep(1000);
>
>
> System.err.println("awake");
> } catch (Throwable e) {
>
>
> e.printStackTrace();
> }
> }
> }
> break;
>
> }
> }
>
>
>
System.err.println("--------------------------DONE--------------------
> ----");
>
> }
>
> //
> // WindowListener methods
> //
> public void windowCreated(int jrexPeerID) {
>
> if (_nativePeerId == -1) {
> synchronized (this) {
> _nativePeerId = jrexPeerID;
>
> this.notifyAll();
> }
> }
> }
>
> public void windowDisposing(int jrexPeerID) {
> }
>
> //
> // JRex state utility methods
> //
>
> public synchronized void waitForNativePeerId()
> {
> synchronized (this) {
> while (_nativePeerId == -1) {
> try {
> this.wait();
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
> }
> }
> }
> }
>
>
> _______________________________________________
> JRex mailing list
> [email protected]
> http://mozdev.org/mailman/listinfo/jrex
>
-----------------------------------------------------------
Nothing's what it seems to be,I'm a replica, I'm a replica
Empty shell inside of me, I'm not myself, I'm a replica of me...
------------------------------------------------------------
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com