[messages] [Module Support] Italia Socket Error issue

uckelman uckelman at nomic.net
Tue Oct 29 03:40:08 MST 2013


The full story is this: Java requires that you specify a maximum amount
of memory a program will use before you start it. This is obviously
problematic when your program loads user-supplied images, because you
have no idea how large they will be beforehand. As a workaround, the
Module Manager checks the sizes of the images which will be loaded and
then starts the image tiler as a separate process, which permits us to
specify a maximum amount of memory for the image tiler which is
appropriate to the images it will be loading. (This is also the reason
why the Module Manager and Player/Editor are not the same process.) So
far, so good.

Unfortunately, Java gives you no reliable way of determining the sizes
objects will have in memory---this, despite that Java requires you to
set the maximum amount of memory you will use when you start a program!
This is utterly braindead, but it is a constraint we must suffer under
so long as we're using Java. Recall that running the tiler in a separate
process was a workaround for not knowing how much memory we'd need. Now
we need a workaround for our workaround, in order to estimate the amount
of memory it will need.

To arrive at that estimate, I ran the tiler on images of various sizes,
measured (from the outside) the amount of memory (in MB) being used by
the JVM in which the tiler was running, and fit a line to the data
points. It turns out that 2.85(4p)/(2^20) + 50, where p is the number of
pixels, gives you a line which is a bit above the data points I
collected. (You'll note that this is a disgusting amount of overhead,
due to the JVM itself and because Java forces us to copy the image at
one point in the process simply to convert the data from a byte array to
an int array.)

This estimate mostly works---except for a few images on OS X, which take
more memory to load than on Linux and Windows USING THE SAME CODE. So,
clearly the JVM on OS X is doing something different behind the scenes
sometimes on OS X, but I can't guess what, as image loading is just data
manipulation. It really should not differ significantly in memory
requirements from platform to platform.

Here[1]'s a build which increases the constant factor from 2.85 to 3.
Does it work for you?

[1] http://vassalengine.sourceforge.net/builds/VASSAL-3.2.9-svn8880-memtest-macosx.dmg


_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=42561#p42561


More information about the messages mailing list