O/H Boris Zbarsky έγραψε:
On 11/2/09 7:40 PM, Georgios Petasis wrote:
But I have a large problem: memory usage is increased by each page I load.
I have used valgrind to debug the memory usage, but nothing that
originates from code seems to be leaked. All leaked objects seem to have
been created inside mozilla libraries.

Have you considered creating a refcount log and seeing where the missing refcounts might be?
Yes, using instructions from https://developer.mozilla.org/en/Debugging_memory_leaks.
But I reach no conclusions...

1) I have no history navigation. I can reload the current page, but I
cannot go back/forward.

Did you enable session history on your nsIWebBrowser?
If it is not on by default, I haven't add any code to enable this. How can I enable this? https://developer.mozilla.org/en/NsIWebBrowser does not offer that many methods.
Also, in my code:
http://tkgecko.svn.sourceforge.net/viewvc/tkgecko/tkgecko/src/TkGecko_Browser.cpp?revision=19&view=markup
(functions Browser::Init & Browser::AttachWindow)
I tried to do the following:

/* Create our session history object and tell the navigation object
* to use it.  We need to do this before we create the web browser
* window... */
mSessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID, &rv);
mNavigation->SetSessionHistory(mSessionHistory);
if (NS_FAILED(rv)) return rv;

But I get the exact same results. mSessionHistory & mNavigation are members of the class, defined in Browser.h:
nsCOMPtr<nsIWebBrowser> mWebBrowser; // [OWNER]
nsCOMPtr<nsIWebNavigation> mNavigation; // [OWNER]

Is there anything else I should do?

WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005: file
/home/backup_disk/petasis/TkGecko/mozilla-central/toolkit/components/places/src/nsNavHistory.cpp,
line 600
WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005: file
/home/backup_disk/petasis/TkGecko/mozilla-central/toolkit/components/places/src/nsNavHistory.cpp,
line 472
WARNING: EnableGlobalHistory() failed: 'NS_SUCCEEDED(rv)', file
/home/backup_disk/petasis/TkGecko/mozilla-central/embedding/browser/webBrowser/nsWebBrowser.cpp,
line 1213

How can I fix this?

Actually have a profile. Those are failures to get the profile directory.
My initialisation happens in functions:

Browser::InitializeXPCOM()
Browser::InitializeXUL()

at the end of Browser.cpp: http://tkgecko.svn.sourceforge.net/viewvc/tkgecko/tkgecko/src/TkGecko_Browser.cpp?revision=19&view=markup.
I simply call

XRE_InitEmbedding(mXulDir, mAppDir, 0, 0, 0);

In the way I call XRE_InitEmbedding, mXulDir = mAppDir, and is the parent directory xpcom.so was found.
Should I use something else?


2) When the application exits, there is a long list of leaked urls. How
can I free them, so as not to get leaked?

That's the same as the very first issue you mentioned. The answer depends on why they're being leaked.
I have the feeling that despite the fact that my AddRef() & Release() are balanced, each page I load remains alive "somewhere".
I don't know where though :-)
3) During exit, I get an abort:

ABORT: imgCacheEntry release isn't thread-safe!:
'_mOwningThread.GetThread() == PR_GetCurrentThread()', file
/home/backup_disk/petasis/TkGecko/mozilla-central/modules/libpr0n/src/imgLoader.h,
line 81
UNKNOWN
[/home/backup_disk/petasis/TkGecko/mozilla-central/obj-xulrunner-d/dist/bin/libxul.so
+0x004C314D]

That indicates that you're shutting down the image cache from a non-main thread. Don't do that.
Well, this needs more investigation from my side. I don't think that I am doing, but perhaps I am wrong. In fact this happens when I call exit, from a thread different than the thread mozilla runs. It seems that mozilla registers some callbacks that trigger on exit, and these are triggered from a different thread?

I think that I have forgot something (what?) that relates to
navigation/cache, and the application keeps everything in memory. Is
this possible?

Unlikely; there are limits on how much is kept in memory...
I tried to reload the same page many times (i.e. 120). The memory used by the application grew up to 500 MB... (It is a few MB when started without loading a page, but with mozilla initialised).

http://tkgecko.svn.sourceforge.net/viewvc/tkgecko/tkgecko/src/

Which thread do the GetProxyFor* functions in http://tkgecko.svn.sourceforge.net/viewvc/tkgecko/tkgecko/src/TkGecko_Browser.cpp?revision=19&view=markup run on?
I have two threads: One provided by the application that wants to embed mozilla (actually a Tcl thread), and one thread I create using glib facilities, where gtk is initialised. Mozilla is initialised in the gtk thread. All GetProxy functions are also called in the gtk/mozilla thread, and the pointer is passed & used in the Tcl thread.

Isn't this the correct usage of GetProxy?

Thank you very much for your time in looking this,

George
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to