On 8 Feb 2001, Jean-Marc Lasgouttes wrote:
> >>>>> "Dekel" == Dekel Tsur <[EMAIL PROTECTED]> writes:
>
> Dekel> The memory consumption can be (slightly) reduced by deleting
> Dekel> the line text.reserve(500) in LyXParagraph::LyXParagraph.
>
> In the example we had, a 50x50 array consumes 1.2M (50x50x500). This
> probably accounts for most of the memory bloat we have been seeing!
>
> Would it be possible when copying a paragraph to undo (or when not
> editing it) to "tighten" it to use a minimal amount of memory? Or
> would that cause a lot of fragmentation?
>
> I'll do experiments tomorrow if nobody beats me to it. What was the
> initial reason for the reserve(500)? speed?
>
> JMarc
>
What about using different values in different contexts - table cells
usually have less text than run-of-the-mill paragraphs. Add an extra
constr. to LyXParagraph getting an 'enum ExpectedSize' value (Tiny, Small,
...) and reserve memory accordingly.
About copying paragraphs for 'Undo' purposes, if this were done using a
copy constructor and not a 'Clone', it would be easy to reserve exactly
the amount of memory needed.
Also, note that on my machine (i686 Linux, g++) sizeof(LyXParagraph) == 232,
and this does not count dynamic memory allocated by the other vectors inside,
or by the cell insets outside.
Thus the reserved text buffer accounts for less than 2/3 of the memory
use. Not to say that we shouldn't reduce it, but perhaps we can find some
ways to save more space. E.g. not allocate anything until the user
actually puts something in the cell.
Lior.