I just got done doing some pretty intense research on one of my apps' memory usage so here are some tips / observations.
- use -verbosegc -XX:+PrintGCDetails vm options to see memory activity on deployed instances if you don't want to or can't profile a deployed app. Google the terms for more info. Also, I use the concurrent sweep collector with much success. Lastly, you can use jmap -histo on the process to get a snapshot without a profiler. - if you're calling the gc manually, there is something wrong. If you're getting OOM errors, the garbage collector has already done all the collection it can and has reached an impasse. System.gc() won't help. Just generally, explicit gc invocation is unnecessary unless you're benchmarking. - in one of my apps, rr loops can generate up to 50 megs of objects that get collected at the next eden collection so long as the young generation is large enough to hold them through the rr loop. Make sure you've set the size of the max memory large enough to keep your Eden and newSize in reasonable limits. Even a basic app can use a gig. Use -xmx1024m to set the max size to a gig, for instance. - reduce the page cache size from the default of 30. You rarely need this many backtrack pages and they consume memory - eliminate or reduce the ec undo stack size. - be careful that you're not keeping references to ecs somewhere other than in a session or page. Likewise, don't keep references to eo objects somewhere. They have strong references to their ec. (the opposite isn't true) - make sure you're not churning sessions somewhere that have long timeouts. A session can't be disposed of until it has been terminated. - lastly, watch for big batch fetches where you keep references in arrays to the results. Big fetches aren't bad if the objects just get stuck in the ec since the ec will have weak refs to them, but if you keep them somewhere else there can be trouble. Hope that helps. :-) John On Nov 30, 2010, at 5:29 AM, Gennady Kushnir <[email protected]> wrote: > Hello list. > I've got "Out of memory" error once, when an app was under significant > load serving multiple users. > I am wondering if there is a way to monitor memory usage and possibly > force garbage-collection of unused objects. > For example, when debugging with MultiECLockManager I noticed that > formerly used editing contexts do not get garbage collected. > > Gennady > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/webobjects-dev/the_larsons%40mac.com > > This email sent to [email protected]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
