Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applets and memory usage



Our applets use a lot of memory, so we have quite a bit of experience with this.

Chances are you are not really running out of memory unless you are allocating 32 bytes of internal representation for every byte of data read. It's much more likely that you are bumping into limits on array size. Netscape 4.79 would not allow you to allocate a single dimensional array larger than 1MB. A 2D array can be much larger, because it allocates each row separately. I'm not aware of any other VM with this particular defect.

The default memory available for all Java's you'll encounter is at least 64MB. The old MS VM allows 128MB by default, and Sun's VM defaults to 64MB minimum, but 96MB on machines with more memory. Apple defaults to 64MB in OS X. In OS 9, it depended on the user's browser settings (which defaulted to something silly, like 4MB for the whole browser application, and would invariably be changed by the user to a much larger number).

This can often be changed with a control panel setting, but every VM is different in how you achieve it. With the Sun VM and on OS X, you add -Xmx128M (for example) to the applet parameters text type-in.

On the machine with an out-of-memory error, start up the Java console before you visit your applet, then type "m" into the console over and over as it loads. This should give you a better idea what's going on.

Hope that helps!

-Joshua

On May 26, 2005, at 4:39 PM, David Leader wrote:

I have just converted a java app to an applet (java version 1.1) of size about 250Mb. This applet reads data from text files which can be over 1 Mb in size. (These are actually files of coordinates etc. from the human and other genome projects. The app is for serious academic use, whereas the applet is more illustrative for use in university teaching - and publicizing the app. on its web page.)

I set up a page with about 2 Mb of text files that worked ok (although taking ca. 10 sec to load) on IE5.1 on Mac OS9. When I tried it on Windows (98, XP) this failed with an out-of-memory error, although a different page with much smaller files was OK. I cut down the size of the files on the problem page (changed bacteria) and it now works on Windows.

My question is, is there any way to increase the memory allocation for an applet? I know how to do this (and with my app, which can load 40MB text files, have to do it) for a java app on the command line, but there isn't any command line for an applet. Looking on the Sun web site, all I can find of relevence is a statement regarding the (presumably Windows) plugin that "Dynamic maximum heap size is scaled down from 128 MB to 96MB to avoid unnecessary paging on the system." which sounds as if it might possibly explain the difference between OS9 and Windows. But then again, what do I know about these things...

Perhaps it would help if the data were accessed in a more sophisticated way?

David

PS I know that applets were meant to be small (and presumably the files they use too), so you could say I shouldn't be doing this. However, if it could be done...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Applets and memory usage (From: David Leader <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.