On Sat, May 24, 2008 at 02:58:08PM +0200, Johannes Hofmann wrote:
Hi,
attached is patch to reduce the memory usage of dw2:
Excellent! (AFAIU this is near 30% memory usage reduction in dw2) Committed.
* Styles are now reused if they are equal. This brings down the number of Style objects on the mysql page from around 180000 to 23000 and reduces memory usage by about 25M at the cost of an additional HashTable. Maybe the hash table should be part of fltkplatform as the hash tables for Color and Font? There would be even more sharing of styles possible, if x_link would not be part of style. On the other hand about 3M for styles on the huge mysql page is pretty ok.
* Size of struct Word is reduced by 4 integers by using shorts. I know that this is questionable, but I think in the case of struct Word that can be allocated a lot it is worth the hassle. Please check whether my assumption that space lengths and word lengths can be stored in shorts are valid in general.
It looks OK at first sight, but to be sure it'd be good to know what happens when the limit is surpassed. BTW, "unsigned short" looks like a good idea for origSpace and effSpace.
Also memory usage gets pretty high (250M with images disabled). I'm experimenting with reducing the size of struct Word in textblock.hh by moving the highlight stuff out of struct Word and into Textblock. This brings memory usage down to 199M. However, I don't know the highlighting stuff enough to be sure I don't break anything. This probabely falls into the "premature optimization" category anyway.
hlStart and hlEnd use -1 as a value, so they can't be unsigned. I don't know whether they can be taken out, and how much impact it can have (alignment issues are strange sometimes).
* SimpleVector no longer preallocates memory if it's not necessary. This actually saves some megabytes here!
With these changes memory usage on the mysql page is 179M here.
Great. -- Cheers Jorge.-