Results 1 to 6 of 6
  1. #1
    tutiplain is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Unhappy General questions about Java Garbage Collection

    Hi everyone,

    First off I'd like to begin saying that I'm new to these forums, but am glad to be here. This seems like a professional and friendly community. Now, a little background: I know the basics of Java, inheritance, interfaces and such, as well as the basics of GUI design and programming with Netbeans IDE and the Swing toolkit, but I am not a professional Java developer, more of an on and off hobbyist. But, I do work professionally with a language that is built on top of Java, which I've been using for the past three years. The language provides mechanisms to use any object that is accessible to Java, or any class, which is a pretty cool feature. But, over the course of time, we've had ocassions when our main application made in this language will freeze up and freeze every user connected to it. On other occassions, the whole thing feels sluggish. At first, stuff like this happened all the time. After we contacted the company which makes the language we use (basis.com), they suggested that we change the -Xmx and -Xms parameters in thr JVM which runs our application. We adjusted these parameters to the numbers they recommended, and the problem was minimized, but still happens from time to time.

    Through some research we found that the freeze-ups happen because the JVM does something called a "Full GC" or Full Garbage Collection, which supposedly frees no-longer-needed objects from memory, but in so doing, stops all other execution.

    So I've been wondering, is there some sort of "magic formula" that we can tweak in the -xmx and -xms parameters so that code execution will ALWAYS be smooth? I've seen many people successfully use Java in many applications, and with the recent success of Android, I gather that there must not be a problem in Java, but rather, that we must be doing something wrong. So, what is it about java garbage collection? How do you guys deal with it, or has anyone even had problems with it? (Note: in the pure Java development I've done, I've never had problems like these)

    Thanks for any advice on this.

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,011
    Rep Power
    20

    Default

    I would look at what it's trying to clear up in a full gc.
    Can you take some heap dumps and analyse them to see what classes it's churning through? That might give you an idea of what's happening.

    There are settings for the gc you can use, but they should not be done without profiling your app and seeing where the memory is going and what is being cleared up.

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,011
    Rep Power
    20

    Default

    SNAP!
    :D

    (10 chars)

  5. #5
    tutiplain is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default

    Hi,

    Thanks for your answers. You mention I should analyze a heap dump from java. I believe you might be reffering to the HPROF files that Java generates. How does one analyze such a file. As far as I can tell, it's only binary data in there, so it possibly can't be read with a text editor. Is there some sort of program to analyze these files?

    I will look into Java profiling tools, as well. Maybe that will give me a clue as to what is happening. Thanks for the advice.

  6. #6
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,011
    Rep Power
    20

    Default

    Eclipse has a plugin, a memory analyser, that can analyse these heap dumps.

Similar Threads

  1. Garbage Collection Question
    By DrMath in forum New To Java
    Replies: 5
    Last Post: 10-03-2009, 10:08 AM
  2. Java Garbage Collection and destructors
    By riddhik84 in forum New To Java
    Replies: 1
    Last Post: 09-30-2009, 09:48 AM
  3. How setting an Object to null help Garbage Collection?
    By piyu.sha in forum Advanced Java
    Replies: 3
    Last Post: 10-06-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •