setting the maximum heap size automatically
I'm working on a program which, as one of its functions, displays some (potentially very large) images contained in a ZIP archive. The amount of heap space used by other objects is almost always insignificant in comparison with the amount of heap space used by these images, and the actual heap requirements can vary wildly depending on the particular images the user is loading.
The architecture of the program is such that one part of it (the "manager") launches child JVM instances for doing the work. This makes it possible for us to set the maximum heap size independently for each child. Presently, the max heap size is set in a preferences dialog. There's a default, which can be overridden individually for each input file. This would be a fine solution for us, except that most of our users don't understand what the maximum heap size is, nor have we ever found any way of explaining how they should set it which seems to make sense for them. As a result, we spend an inordinate amount of time providing user support on this issue.
My gut feeling is that this is a problem that the user should never be confronted with in the first place---that the manager program should be able to determine how to set the max heap for its children without any input form the user. At this point, we hit a wall: We have no clue how to estimate what a reasonable max heap size will be before the child is started, as this seems to depend on how the user will use the archive opened by the child. Maybe the user will need one image open at a time, maybe five. It occurred to me that something adaptive might work---if we run out of memory this time, then we increase the max heap somewhat for next time---but, among other things, I have no intuitions about what the increase should be like or on what it should depend.
Has anyone else here faced this problem and found a solution for it? I have a hard time imaging that I'm the first person to encounter this, but I turned up nothing relevant on the web after multiple tries.