cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylvain.wal...@anyware-tech.com>
Subject Re: NotSerializableException in MemoryStore
Date Mon, 07 May 2001 12:22:25 GMT


gerhard a écrit :
> 
> Hi,
> I'm broaden the MRUMemoryCache. My idea is not to limit the number
> of objects rather the size in bytes. Ok there is no sizeof method in java.
> Because of that I have to serialize every object which wanted to be
> holden in the cache to get the size in bytes.
> 
> My problem is that some objects doesn't implement the serializable interface.
> Like instances of CachedStreamObject. When I serialize those object I get
> a NotSerializableException. That's understandably :-). How could I solve this
> problem nicly.
> My first idea:
> CachedStreamObject  implements Serializable
> ...
> 
> But I don't know if there are any more classes, where the serializable interface
> have to be implemented for determine there size in bytes.
> 
> Better ideas, suggestions?
> cheers
> Gerhard
> 
I'm not sure measuring the size of an object with the size of it's
seraialized representation is a good idea :
- serialization adds a lot of data (e.g. class names) to the actual
memory used by the object
- serialization traverses the whole dependency graph. If all the objects
you cache reference some non-cached components, these components will be
traversed and their size added for each and every cached object
- serialization is CPU-intensive and this may be overkill just to
compute and object's size...

I remember having seen once on the web a "Sizeable" interface declaring
a "int getSizeInBytes()" method that returns and estimate of the
object's size. We could imagine a MemoryLimitedCache that accepts
Sizeable objects. And since the Cocoon cache is mainly filled with
byte-arrays representing SAX event streams, implementing the interface
should be easy.

Thoughts ?

-- 
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message