Prevayled flyweight strings
Karl Wettin <[email protected]>
| Newsgroups | gmane.comp.java.prevayler |
|---|---|
| Message-ID | <[email protected]> |
In my application there is a lot RAM to be saved by flyweighting Strings -- I have lots and lots of reoccuring address components. I do however belive that String.intern is not applicable as it will loose the state when restarting and I would thus have to add my own flyweight to the Root. Is there any specific solution you would recommend? I was simply thinking a Map<String, String> where key and value is the same instance. I think the GOF-bible speak of another solution but I can't seem to find it in my library. They probably over complicated things. But this should be a rather common use case of Prevayler, right? One alternative to the Map I can think of is to programmatically iterate all my flyweighted values on initialization of the system, calling String.intern. Not sure if I can trust all JVMs to act the same way though -- ie using the first interned value as the flyweighted value. Nor am I sure it would save RAM. It would however make it slower to start up the system. Any thoughts most welcome. For now I'm going with the Map. karl ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion _______________________________________________ "Databases in Memoriam" -- http://www.prevayler.org