Jason,
I now do javac compiles with -J-mx64m (which works fine even on my
48Mb RAM laptop). Using top I often watch the memory utilization
creep into the swapfile. (I know, I know, I should be using jikes!)
Sorry I don't know what's up with totalMemory(). If no better
solution is found, I understand you can catch subclasses of Error as
well as Exception. So as a last resort you could have a watchdog
thread that periodically allocates and disposes of a large block of
memory, then warns you somehow when it cannot.
Michael
> Is there any way to get the maximum heap size from inside java. I though that
> Runtime.totalMemory() would return that, but it does not. I current am running
> one vm with -mx50m and totalMemory() is returning 5242872, which is about 5mb
> not 50mb... unless I am totally crazy.
>
> I am running into a problem where my vm grows too big, to fast (faster than the
> consumers of the collected data can consume it), resulting in a
> OutOfMemoryError in all running threads. I changed the vm to run with -mx50m
> and it ran for much longer (about 5 days) then it too did the same thing.
>
> Currently I am trying to add some sort of alert before it runs out of memory,
> mostly for debugging purposes, but it seems like the set of methods to access
> memory do not take into account the maximum limits passed in via -mx. I can
> see that this is a good thing, because I could tell it that it has some insane
> amount of memory when it really has a few megs... but is there a happy medium?
>
>
> If anyone has run into memory problems and found suitable solutions I would
> like to hear about them.
>
> --jason
>
>