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.

Results 1 to 13 of 13

Thread: applet out of memory error (how to increase available heap space)

  1. #1
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default applet out of memory error (how to increase available heap space)

    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).


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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.

  3. The Following User Says Thank You to Norm For This Useful Post:

    KAJLogic (July 7th, 2014)

  4. #3
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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.

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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.

  6. The Following User Says Thank You to Norm For This Useful Post:

    KAJLogic (July 8th, 2014)

  7. #5
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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.

  8. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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.

  9. The Following User Says Thank You to GregBrannon For This Useful Post:

    KAJLogic (July 8th, 2014)

  10. #7
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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?

  11. #8
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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.

  12. #9
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    AWT isn't thread safe either.
    I wasn't implying that it was, just that I design all my GUI (aside from Component, and the event APIs).

    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.

  13. #10
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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!

  14. #11
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    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.

  15. #12
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    Applets are not allowed to load certain classes I guess.
    Can you give an example? What was the exception being thrown?
    Additionally, I had a loop without any way of exit (no sleep either) which bottle necked the memory.
    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?

    Thanks for adding the details.

  16. #13
    Member
    Join Date
    Sep 2013
    Posts
    102
    Thanks
    38
    Thanked 0 Times in 0 Posts

    Default Re: applet out of memory error (how to increase available heap space)

    Can you give an example? What was the exception being thrown?
    IllegalAccessException

    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?
    That loop was in charge of doling out instructions for image loading processes.

Similar Threads

  1. Facing OutOfMemoryError Java Heap Space error
    By kodamv in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 21st, 2014, 01:18 PM
  2. Java heap memory error
    By geethauma in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 12th, 2013, 10:20 AM
  3. Increase heap size; 4 GB wall?
    By BKB in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 13th, 2010, 08:55 PM
  4. Java heap space error
    By Loki in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 27th, 2010, 10:47 PM
  5. Out of memory - Java heap space
    By fraxx in forum Java Theory & Questions
    Replies: 4
    Last Post: November 24th, 2009, 05:26 AM