Re: Avoiding java.lang.OutOfMemoryError: Java heap space
Re: Avoiding java.lang.OutOfMemoryError: Java heap space
- Subject: Re: Avoiding java.lang.OutOfMemoryError: Java heap space
- From: Gennady Kushnir <email@hidden>
- Date: Wed, 23 Jun 2010 15:31:51 +0400
Thanks to all.
Susanne, in fact my background pages should not be stored because I
initialize my dummyContext to deny page storing:
WOContext dummyContext = new WOContext(request) {
public boolean shouldNotStorePageInBacktrackCache() {
return true;
}
};
I have tested this and mentioned that whereas WOSession.savePage() is
invoked for my page
but savePageInPageCache() is actually not. So I assume the page is not
actually saved.
Farrukh, I've added EOEditingContext creation and dispose() into the
loop. It did help, thank you.
But I thought that editing context does not hold strong references to
its objects and so unnecessary ones should be garbage collected...
Well whereas I'm happy that my code is working right now I'm still not
sure that such problems won't revive once.
Could anyone suggest how to keep track of memory usage in my
application and how to tell what is consuming memory in the moment.
Gennady
2010/6/23 Susanne Schneider <email@hidden>:
> Hi Gennady,
>
> we are doing similar background tasks here. To avoid memory problems we
> declared the generated HTML pages not to be stored into the page cache. This
> background pages implement the Interface IASUnsaveablePage:
>
> public interface IASUnsaveablePage {
>
> /**
> * defines if this page should be saved in the WO page cache
> *
> * @return returning true is the same as not implementing
> * the interface
> */
> public boolean shouldBeSavedInPageCache();
> }
>
> and in our custom session class we override savePage():
>
> /**
> * implements the meachanism for the IASUnsaveablePage
> *
> * @see IASUnsaveablePage#shouldBeSavedInPageCache()
> */
> @Override
> public void savePage(WOComponent page) {
> if (!(page instanceof IASUnsaveablePage)
> || ((IASUnsaveablePage) page).shouldBeSavedInPageCache()) {
> super.savePage(page);
> }
> }
>
> Maybe you could use a similar approach?
>
> HTH,
> Susanne
>
>> Hello List!
>>
>> I have a task to form an archive of a good bunch of WO-generated HTML
>> pages to HDD.
>> To achieve this I create a background thread to perform the task.
>>
>> In this thread I create a dummy WOContext :
>>
>> WOApplication app = WOApplication.application();
>> String dummyUrl = app.cgiAdaptorURL() + "/" + app.name() +
>> ".woa/wa/dummy";
>> if(ses != null) {
>> dummyUrl = dummyUrl + "?wosid=" + ses.sessionID();
>> }
>> WORequest request = app.createRequest( "GET", dummyUrl,
>> "HTTP/1.0",
>> null, null, null);
>> WOContext dummyContext = new WOContext(request) {
>> public boolean shouldNotStorePageInBacktrackCache()
>> {
>> return true;
>> }
>> }
>>
>> After that in a loop I prepare my pages (in fact there are several
>> WOComponent's in work):
>>
>> WOComponent page =
>> WOApplication.application().pageWithName("MyPageName", dummyContext);
>>
>> and write them to HDD:
>>
>> NSData content = page.generateResponse().content();
>> content.writeToStream(fileOutputStream);
>>
>>
>> The problem is that when the loop is long and the page contents is
>> complex my JVM runs out of memory.
>> What am I doing wrong? It seems like WO is storing something
>> unnecessary, how should I tell it to forget that?
>> At least how can I diagnose what exactly the memory is filled with?
>>
>> Gennady
>>
>
> --
> Susanne Schneider
> Coordinator secuTrial Development
>
> iAS interActive Systems GmbH
> Dieffenbachstraße 33 c, D-10967 Berlin
>
> fon +49(0)30 22 50 50 - 498
> fax +49(0)30 22 50 50 - 451
> mail email@hidden
> web http://www.interActive-Systems.de
>
> ----------------------------------------------------
> Geschäftsführer: Dr. Marko Reschke, Thomas Fritzsche
> Sitz der Gesellschaft: Berlin
> Amtsgericht Berlin Charlottenburg, HRB 106103B
> ----------------------------------------------------
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden