>On the subject of memory optimization--looking at the code that actually
>writes a workbook to a stream (HSSFWorkbook.write method), I noticed that it
>serializes the whole document into a byte array (using Record.serialize
>method), then copies the byte array to the OuputStream.
Well you cannot use an OutputSTREAM directly coz you cannot stream!
You need the byte array to do the out-of-order writing. If you then pipe it to a FileOutputStream, then that doesnt take any extra memory, since that writes to disk (modulo caching etc).. we need to keep the entire byte array in memory, thats what takes space...
>
> -------Original Message-------
>
> > From: Robert Lowe
>
> > Subject: RE: RE: RE: Event-based API for generating Excel files?
>
> > Sent: 28 Oct 2003 23:49:33
>
> >
>
> > > Yeah, sorry, i think that WAS the point of your original mail, but it got
>
> > lost in the conversation somehow... most of us take the architecture advice
>
> > of web servers to heart.. be stateless to be scalable .. :)
>
> >
>
> > I accept cookies if that's any help. :)
>
> >
>
> > > But anyways... It is, in general, not possible to stream the writing of an
>
> > excel file, since the file structure contains upstream pointers to
>
> > downstream data.
>
> >
>
> > Yeah, I kind of suspected that.
>
> >
>
> > > The changes in HEAD do not address this issue.. all that they do is
>
> > optimise the memory usage of POI , ensuring that the same data is not stored
>
> > twice etc. It should cause a 30-40% reduction in POI memory as well as time
>
> > for large workbooks.
>
> >
>
> > On the subject of memory optimization--looking at the code that actually
>
> > writes a workbook to a stream (HSSFWorkbook.write method), I noticed that it
>
> > serializes the whole document into a byte array (using Record.serialize
>
> > method), then copies the byte array to the OuputStream. It occurred to me
>
> > that one could do away with the byte array and simply have the serialize
>
> > method write directly to the OutputStream--seems like that could reduce the
>
> > memory usage by quite a large factor. Does that make sense or am I missing
>
> > something?
>
> >
>
> > > The solution for streaming like access currently proposed is to user the
>
> > RandomAccessFile. Chris has proposed such a solution.. but not many people
>
> > have actually worked with that solution.
>
> >
>
> > Doesn't sound like a RandomAccessFile would work for me--I want to stream
>
> > directly across a network...
>
> >
>
> >
>
> >
>
> > Best regards,
>
> >
>
> > Robert Lowe
>
> > http://RMLowe.com/
>
> -------Original Message-------
-------Original Message-------
