• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Out of memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Out of memory


  • Subject: Re: Out of memory
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 28 Jun 2007 08:26:02 -0700


On Jun 28, 2007, at 1:54 AM, Muckenhirn, Ralf wrote:

 Hello,



I know there were some big discussions about that problem before. But I have not found any solution for my problem until now.

I’ve created a small and very simple web-service using WebObjects to reproduce my problem (see below). I then calling this web- service from a small application by invoking with axis every 200ms.

When looking to the used memory of my web-service it will grow continuously over the time. After a while (maybe 30 min to 1h) I get a java.lang.OutOfMemory: Heap overflow error.

I’ve tried a lot of things like revert, invalidateAllObjects, dispose (where I get a java.lang.IllegalStateException).

Also increasing the max heap size for the JVM does not help. The error appears only later.

I’ve used JProfiler to profile the web-service and found the most (also increasing) memory usage in editingContext ()._initWithParentObjectStore().

I’ve tried this example on a WindowsXP with WebObjects 5.2.4 as well on a Apple XServe with WebObjects 5.3.

Some bad things are happening:

public class MyService implements IMyService {

public void storeToDB(String text1, String text2, String text3, String text4, String text5) {

WOSession session = WOWebServiceUtilities.currentWOContext().session();

EOEditingContext ec = session.defaultEditingContext();
Why create a session? If you have not changed the defaults, this session, and its editing context and the objects you create etc. etc are going to live in your app for the next _hour_. Of course memory usage continually increases!

            //ec.setUndoManager(null);

            ec.undoManager().disableUndoRegistration();



            MyLog myLog = new MyLog();

            myLog.setCol1(text1);

            myLog.setCol2(text2);

            myLog.setCol3(text3);

            myLog.setCol4(text4);

            myLog.setCol5(text5);

ec.insertObject(myLog);
You are violating EOF commandments. See http://en.wikibooks.org/wiki/ Programming:WebObjects/EOF/Using_EOF/The_EOF_Commandments
            ec.saveChanges();

      }

}



Any ideas?
Yes.  This code should be:


public void storeToDB(String text1, String text2, String text3, String text4, String text5) {
EOEditingContext ec = new EOEditingContext();
ec.lock();
try {
MyLog myLog = new MyLog();
ec.insertObject(myLog);
myLog.setCol1(text1);
myLog.setCol2(text2);
myLog.setCol3(text3);
myLog.setCol4(text4);
myLog.setCol5(text5);
ec.saveChanges();
finally {
ec.unlock();
ec.dispose();
}
}



Chuck


--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
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


References: 
 >Out of memory (From: "Muckenhirn, Ralf" <email@hidden>)

  • Prev by Date: Problem with a form
  • Next by Date: Re: Out of memory
  • Previous by thread: Re: Out of memory
  • Next by thread: Profiler for production
  • Index(es):
    • Date
    • Thread