How do you handle OutOfMemoryError ??


Sometimes, depending on a lot of circumstances, Eclipse user can face the famous OutOfMemoryError. Unfortunately our users sometime face this error.

Eclipse default handling for such errors prompts the user as following:

Out Of Memory handling

Out Of Memory handling

I am asking myself: is there any more useful information we can provide to the end user in order to prevent such errors to occur again ???

May be I can parse the Error message to check if it’s a heap or permanent generation out of memory ? Thus I will be able to tell the user: add the following option when launching the product.

It also appears that sometimes this dialog is not opened, and the error is only logged in the .log file. Does it depends on the thread throwing the error …

Do you handle these errors differently than Eclipse in you custom products ? If yes, how ?

I would be interested in any comments suggestions on that topic.

Manu

Advertisements

10 thoughts on “How do you handle OutOfMemoryError ??

  1. Manu,

    When you catch an OutOfMemoryError, you have to be extremely careful, and what you can do is limited by the fact that memory is running low. So for example, anything you do that involves allocating more memory (including opening a dialog, writing to the log etc) could potentially throw another OutOfMemoryError. This is why the error message is so basic, and might be the reason that sometimes we only log without opening the dialog. OOMEs happening on non-UI threads probably get handled differently, too.

    I’d be interested to hear any ideas that others might have on how to better handle these kinds of situations.

  2. I am not very sure anything can be done here.

    If you are a developer, or know a bit about Eclipse, you will look into the log file and can work out whether a startup option will save you.

    If you are not a developer, I don’t think they even know how to set the options. Do you really want to teach them how to run eclipse from command line, or modify eclipse.ini file? In either case, most users I encounters will be very hesitant to do either.

    But here is one thing I recommend: Make the log file more readable:

    (1) If log file name is “.log”: Normally there is a lot of logfiles in the directory. I do not really want to read a long string of random number, especially when it is very likely that I have to read at least 5 or 6 digit before I can uniquely identify the log file.

    (2) If long file name is “.log” : Normally, Eclipse just append the new log data in the beginning of the file, or at the end. In either case, there are a lot of rubbish to go through. In the latter case, a lot of scroll down before you get to the log entry of interest.

  3. Well obviously providing some information on the relevant steps to take to fix this could be helpful, especially since the steps are not exactly obvious. Additionally actually displaying the values of relevant memory parameters would be nice.

    And finally, those should of course be editable through the preferences (all along with some reasonable sets of alternatives, common optimizations, and automatically detected best settings – why use only 256MB of a desktop with 4GB). Memory problems are as old as eclipse itself and the solution has always been command line voodoo in some .ini file. How hard can it be to provide an editor for this thing?

  4. I used to program the mac in the ‘good old days’ when you had to set memory limits on mac applications. Here are some things people did.

    1. reserve a memory buffer you can free when you have an out of memory situation. When memory is exhausted free the memory reserve so that the user can do reasonable things and be informed (shutdown, save files, show dialogs to advise the user what to do, etc)
    2. disable meu items that create new things or use memory (opening windows etc) but allow the user to close files etc so they can rescue the situation.
    3. monitor memory and when the the low memory situation is resolved reacquire your memory buffer and re-enable the menus items etc that will allow users to chew more memory

    hope that helps regards
    gary

  5. Pingback: -Xms Question for long (French) week end « Manuel Selva’s Eclipse blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s