[Chicago-talk] neat little optimization
Steven Lembark
lembark at wrkhors.com
Thu Oct 14 09:36:37 CDT 2004
> So for example, you can memoize the call to new() for some class, and
> then every time a user creates an instance of that object with the
> same params as one that's been created before, new() will return the
> first object it created.
Which works up to the point where the object is used to buffer
data specific to the invocation and ends up overwriting its
internals. This also tends to get ugly under threading since
you have to synchronize the cache hits.
For fairly simple data it works nicely, but nested data struct's
in threaded or forked environments can easily step on memoized/
flyweight initialization.
It isn't a bad thing, just one more tool that has to be used
carefully.
--
Steven Lembark 85-09 90th Street
Workhorse Computing Woodhaven, NY 11421
lembark at wrkhors.com 1 888 359 3508
More information about the Chicago-talk
mailing list