I was wondering where is the memory allocated for an applet; by the browser; by the JVM; some applet specific java option? I get an out of memory error when running my applet (loading pictures).
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I was wondering where is the memory allocated for an applet; by the browser; by the JVM; some applet specific java option? I get an out of memory error when running my applet (loading pictures).
You might have to control what is loaded and not load them all at once.
If you don't understand my answer, don't ignore it, ask a question.
KAJLogic (July 7th, 2014)
That is what I was thinking, but I there must be some reason why running as an applet reduces my available memory? I mean it is not even close when running on my computer. Do you know where the bottleneck is between the JVM and my applet?
Last edited by KAJLogic; July 7th, 2014 at 05:35 PM.
The only idea I have would be to look at the Java icon in the Control Panel. There might be some settings there.
If you don't understand my answer, don't ignore it, ask a question.
KAJLogic (July 8th, 2014)
I am getting such varied responses on the applet. My applet was running fine, then I added two additional images and everything got disrupted. I even switched to loading all data on the fly when it was needed, but that doesn't seem to completely remedy the problem (no more memory error though). Additionally, some times if it is running slow it seems to dump threads randomly or something causing haphazard errors. Is this just the world of java plugins (e.g java ran through the browser). It feels like I'm dealing with some C programmers shitty java interface .
Last edited by KAJLogic; July 8th, 2014 at 01:46 AM.
Now what you're describing sounds like a Swing app constructed and/or run improperly. Are there multiple threads - real Threads? Thread.sleep()s? There shouldn't be. But I won't go on with the list of things that you might have done wrong that could be causing the problems you've described.
In order for us to be helpful, you need to post some code, preferably code that demonstrates the problem. If that is too hard due to heavy graphics, then post the relevant parts that build and run the Applet (hopefully, JApplet) with any app control logic that controls the timing of execution and/or animation of the app.
KAJLogic (July 8th, 2014)
Well I'm not using any swing API, and I believe I practice thread safety quite well; on top of that the program runs on my computer fine, and the memory is lower than even chrome with a couple youtube tabs. I think I will just shy away from applets; the lack of information available to me about how applets are ran is crippling. I would love to have the exact code that deals with my applet. From examining my code the only conclusion is IE is dropping threads for some reason.
So my question is does this sound crazy to you? Does it just sound like I have a poorly written applet? Or, is what I'm saying valid? Because to me, it seems that the browser is causing problems.
P.S: Also, I hate that I have to sign my applet through some group of racketeers. What gives that group the right to police applets?
AWT isn't thread safe either. Why you'd use AWT rather than Swing is a mystery.
All Java source code is available for you to examine.
The browser does not "drop threads," so I'm not sure what you suspect is happening. When you use threads within a framework that is declared to be "not thread safe," you're subject to experiencing the behaviors you describe. The reason(s) for these behaviors and how to avoid them are well documented in several very thorough papers available on the 'net.
I wasn't implying that it was, just that I design all my GUI (aside from Component, and the event APIs).AWT isn't thread safe either.
I will look into the browsers java plugins and how they are ran, but let me be very clear. My threads are VERY meticulously designed, and I have tested them (not only through running it in my own sandbox, but under specific situations for particular thread watching). I make good use of synchronized methods, variables, and exception handling.
Last edited by KAJLogic; July 8th, 2014 at 02:45 PM.
I missed you saying that your design is largely custom. Because of that, you know more about your code and what could be happening (or not) than anyone here. Not sure what help you expect from Java SE rangers who've never seen your code.
There are ways to help the garbage collector do its job - mainly by releasing references to objects that have been created - but also limiting the objects created, reusing those that are created, setting those to null that are no longer needed, etc. These tips along with others I've surely forgotten are listed in the book "Effective Java."
I'd be interested to hear if you find a root cause and general solution that might be helpful to others.
Good luck!
Applets are not allowed to load certain classes I guess. So my thread watcher gained an exception and kept on trucking (as it should), but I was unable to access the proper variables to set them to null and free up space. Additionally, I had a loop without any way of exit (no sleep either) which bottle necked the memory.
Can you give an example? What was the exception being thrown?Applets are not allowed to load certain classes I guess.
Was the loop akin to a while ( true ) loop? That would capture the attention of that thread, causing uncertain execution of the rest of the code in that thread, but how was the memory impacted. Was that loop creating objects?Additionally, I had a loop without any way of exit (no sleep either) which bottle necked the memory.
Thanks for adding the details.
IllegalAccessExceptionCan you give an example? What was the exception being thrown?
That loop was in charge of doling out instructions for image loading processes.Was the loop akin to a while ( true ) loop? That would capture the attention of that thread, causing uncertain execution of the rest of the code in that thread, but how was the memory impacted. Was that loop creating objects?