From: Janek Kozicki (janek_listy_at_[hidden])
Date: 2006-10-08 09:15:52
JOAQUIN LOPEZ MU?Z said: (by the date of Sun, 08 Oct 2006 13:21:04 +0200)
> Well, the short answer is that flyweight won't gain you
> nothing wrt to shared_ptr, since flyweight objects contain
> a pointer (much like shared_ptr's) which is 8 bytes in 64bit
> The long answer is, given the flexibility that the
> componentized nature of flyweight allows, it is possible to
> devise a factory adaptor that limits the capacity of the
> factory *and* let the flyweight object use internally a
> handle value smaller in size than a pointer (an index of size
> unsigned short, for instance). I will try to write something
> along this line, I'll keep you informed.
many thanks. This is the feature I'm looking for.
Consider my first example about serialization. The variable names in
classess have names with various length, eg: "foo", "bar",
"my_cool_foo_bar_controller", etc. Their length varies, but in some
cases average length is shorter than 8 characters (64 bits), therefore
only this size reduction (8 bytes -> 1 byte) gives an improvement.
In the case of std::string("foo"); we actually lose 5 bytes of memory on
amd64 with flyweight (minus some additional storage data that
std::string might use..) ;)
-- Janek Kozicki |