On 9/10/08, Micha Nelissen <[EMAIL PROTECTED]> wrote: > > TCharacter and TString to be more intelligent with what encoding it > > represents etc... And if you have an application with many strings, it > > might actually save memory, because flyweight objects are used from a > > pool. > > > > Save memory? > 1) storing information for each character > 2) pool retains old classes I assume, so consumes unused memory; how can > this ever save memory?
Please read the following... http://exciton.cs.rice.edu/JavaResources/DesignPatterns/FlyweightPattern.htm http://en.wikipedia.org/wiki/Flyweight_pattern Design Patterns - Elements of Reusable Object-Oriented Software (aka GOF book) "Most contemporary document editors don't use an object for every character, presumably for efficiency reasons. Calder demonstrated that this approach is feasible in his thesis [Cal93]. Calder's glyphs can be shared to reduce storage costs, thereby forming directed-acyclic graph structures. We can apply the Flyweight pattern to get the same effect." ― A Case Study (chapter) [Cal93] - Paul R. Calder. Building User Interfaces with Lightweight Objects. PhD thesis, Stanford University, 1993. Also related to your point (2). Reference counted objects can be used. So "old" objects get freed automatically. Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel