Re: Using a certain percentage of the JVM storage
On Thu, 18 Sep 2008, John W Kennedy wrote:
Tom Anderson wrote:
On Thu, 18 Sep 2008, Lew wrote:
It is the idiomatic pain of Java that programmers have to pay very close
attention to resource release.
I wonder if the solution is thus not to do the buffering in java. The OS
does buffering, right? And it's in a very good position to balance
buffering against RAM demand - i know that doing that well was something
that made FreeBSD fast back in the 90s, and i assume everyone does it now.
So, how about doing a minimal amount of buffering on the java side (just up
to a few KB) and then just writing everything, and letting the OS handle
the buffering?
Bad idea. From a portability viewpoint, you don't know how well or how much
the OS buffers,
Realistically, how much does that vary?
and, from a performance viewpoint, you're making far more trips through
the dispatcher than you otherwise would.
True. But you're also using less memory.
And, pragmatically, I can tell you that you get something like a 9,000%
performance degradation.
A remarkably specific number!
I wasn't advocating no buffering, for precisely that reason. Using a
buffer of, say, 8 kB would mean you weren't doing a syscall every time you
wrote a byte. But it would also mean you weren't using tons of memory. 8
kB might not be the right size - but i can't believe that arbitrarily
large buffers are the right solution here.
Mapped files, Buffered streams or readers/writers, and hand-made buffers
are all much better than relying on OS buffers.
Even in the context of Stefan's problem?
tom
--
got EXPERTISE in BADASS BRAIN FREEZE