cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "gerhard" <g-froehl...@gmx.de>
Subject Re: NotSerializableException in MemoryStore
Date Thu, 10 May 2001 23:07:03 GMT
> > 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...
Those are good arguments. As mentioned above my proposal
is just workaround I'm not lucky with it. I also agree with you, that
performance problens would be possible (FYI: Cocoon objects have ~10-20KB)
> 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.
Sounds not bad at all...

Besides. Dims maked the proposal to swap older objects out on
the filesystem. Therefore cocoon objects should be serializable, or not...
> Thoughts ?
Many :-)

cheers
Gerhard


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


Mime
View raw message