You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by hitendrapratap <hi...@target.com> on 2017/01/06 19:48:19 UTC

Size of an Object

I am caching a big object ON HEAP and want to the get the exact space its
occupying in the cache. So that we can get an idea how many entries we can
cache. Is there any metrics which can achieved the same?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Size-of-an-Object-tp9945.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Size of an Object

Posted by vkulichenko <va...@gmail.com>.
getHeapMemoryUsed gives the total amount of heap memory used. This includes
all overheads introduced by Ignite, any short living objects and even
garbage that is not collected yet. Monitoring it is a good idea when running
test or benchmarks with all data loaded, but it will not give you an
estimate of how much one value consumes.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Size-of-an-Object-tp9945p10005.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Size of an Object

Posted by hitendrapratap <hi...@target.com>.
I am getting different numbers for the size of an object. I cached only 1
object. 

Using the below approach, its 107699 bytes
byte[] arr = ignite.configuration().getMarshaller().marshal

And using cluster get heap memory used, its 846769208 bytes
igniteInstance.cluster().metrics().getHeapMemoryUsed() 

Not sure why the numbers are different?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Size-of-an-Object-tp9945p10004.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Size of an Object

Posted by Duke DAI <du...@gmail.com>.
I had same question and verified the reference https://apacheignite.readme.
io/docs/capacity-planning-bak by API
igniteInstance.cluster().metrics().getHeapMemoryUsed() and MemoryMXBean
with simple program. The reference is accurate:)

Best regards,
Duke
If not now, when? If not me, who?

On Sat, Jan 7, 2017 at 6:23 AM, vkulichenko <va...@gmail.com>
wrote:

> You can serialize the object and check the length of the byte array:
>
> byte[] arr = ignite.configuration().getMarshaller().marshal(new
> Person(10L,
> "first", "last"));
> System.out.println(arr.length);
>
> Then refer to this page to calculate the total cache capacit:
> https://apacheignite.readme.io/docs/capacity-planning-bak
>
> -Val
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Size-of-an-Object-tp9945p9951.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: Size of an Object

Posted by vkulichenko <va...@gmail.com>.
You can serialize the object and check the length of the byte array:

byte[] arr = ignite.configuration().getMarshaller().marshal(new Person(10L,
"first", "last"));
System.out.println(arr.length);

Then refer to this page to calculate the total cache capacit:
https://apacheignite.readme.io/docs/capacity-planning-bak

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Size-of-an-Object-tp9945p9951.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.