memory size of objects
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Leos_Literak
Posted On:   Wednesday, July 17, 2002 03:29 AM

Hi,


I'd like to build memory limited cache. For example configure it, that objects hold by this cache cannot occupy more than 2 MB. The problem is, how to "measure" object. There is no standard method in Java, as I know.


Is there any way how to do this? If not, I will probably use Runtime.getFreeMemory(), which is far from perfect. Any other idea? Thanks

Re: memory size of objects

Posted By:   Lasse_Koskela  
Posted On:   Wednesday, July 17, 2002 04:43 AM

Have you looked towards piping the ObjectOutputStream with, say, ByteArrayOutputStream? ByteArrayOutputStream has method size(), which seems to be what you need.
About | Sitemap | Contact