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 Fri, 11 May 2001 09:27:29 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...
> 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...

Serialization is the easy way from the implementors point of view, but
will require careful inspection of serialized objects to make some
attributes transient in order to reduce the dependency graph, and
rebuild their value at deserialization time. The problem is that this
isn't possible for CacheValidity objects, which can be application
specific...

An other alternative would consider that Cocoon cached objects are
composed of cache validity objects and a byte array. The byte array
being the biggest, we could swap only this one to disk and keep validity
objects in memory. We could define a kind of Swappable interface and
call swapIn()/swapOut() to read/write the byte array from/to disk.

> > Thoughts ?
> Many :-)
Good ;-)
> 
> cheers
> Gerhard
> 

-- 
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