Re: How to tell memory size of an object?

4 views
Skip to first unread message

Martin Piskernig

unread,
Sep 7, 2015, 8:40:16 PM9/7/15
to eiffel_...@yahoogroups.com

Am Dienstag 12 Januar 2010 13:00:36 schrieben Sie:
> Is there a way to tell how much memory and object takes?

Yes, please have a look at class INTERNAL. It has some queries like e.g.
deep_physical_size(o) which will give the total size of object "o".

Regards,
Martin


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/eiffel_software/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/eiffel_software/join
(Yahoo! ID required)

<*> To change settings via email:
eiffel_soft...@yahoogroups.com
eiffel_softwar...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
eiffel_softwa...@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Emmanuel Stapf [ES]

unread,
Sep 7, 2015, 8:46:37 PM9/7/15
to eiffel_...@yahoogroups.com

The signature of `deep_physical_size' is:

deep_physical_size (o: ANY): INTEGER

which means that whatever you pass to it is transformed into a full fledge object
which is 24 bytes on 32-bit platform at the minimum (and 32 bytes on 64-bit
platform).

Use the constants defined in the PLATFORM class to find out how much space basic
types do take.

Regards,
Manu

> -----Original Message-----
> From: eiffel_...@yahoogroups.com
> [mailto:eiffel_...@yahoogroups.com] On Behalf Of brucemount
> Sent: Thursday, January 14, 2010 6:17 AM
> To: eiffel_...@yahoogroups.com
> Subject: [eiffel_software] Re: How to tell memory size of an object?
>
> Martin (others):
>
> I used 'deep_physical_size' from INTERNAL which (according to the comment
> in the code) returns "Space occupied by `object' and its children in
> bytes" and got this surprising result:
>
> CHARACTER_8 size: 24
> INTEGER_8 size: 24
> INTEGER_32 size: 24
> INTEGER_64 size: 24
> NATURAL_8 size: 24
> NATURAL_16 size: 24
> NATURAL_32 size: 24
> NATURAL_64 size: 24
>
> Is it really true that expanded types take 24 bytes of storage, no matter
> what the size? It don't understand how a NATURAL_8 and a NATURAL_64 can
> take the same storage size.
>
> Am I doing something wrong?
>
> --Bruce
> ======================================
> > Martin Piskernig <martin.piskernig@> wrote:
> > > Am Dienstag 12 Januar 2010 13:00:36 schrieben Sie:
> > > > Is there a way to tell how much memory and object takes?
> > >
> > > Yes, please have a look at class INTERNAL. It has some queries
> > >like e.g. deep_physical_size(o) which will give the total size
> > >of object "o".
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links

brucemount

unread,
Sep 8, 2015, 2:48:04 AM9/8/15
to eiffel_...@yahoogroups.com


Thanks Manu! I was sure I was doing something wrong.

--Bruce

--- In eiffel_...@yahoogroups.com, "Emmanuel Stapf [ES]" <manus@...> wrote:
> Use the constants defined in the PLATFORM class to find
> out how much space basic types do take.





brucemount

unread,
Sep 8, 2015, 2:48:52 AM9/8/15
to eiffel_...@yahoogroups.com


Is there a way to tell how much memory and object takes? The profiler tells me the relative execution times of features. I'm looking for a "memory profiler" that allows me to compare relative memory sizes of objects.

I have a system that is running out of memory at run time (I have 3 GB of RAM and can't expand further). I have run 'full_collect' to eliminate garbage, but now I'm considering creating new classes that will store data in a compressed form.

Is there some way to compare the memory footprint of an object so I can "memory profile" my designs?

Thanks,

--Bruce

brucemount

unread,
Sep 8, 2015, 2:48:52 AM9/8/15
to eiffel_...@yahoogroups.com

Martin:

This is exactly what I wanted, thank you!

--Bruce

Martin Piskernig <martin.piskernig@...> wrote:
> Am Dienstag 12 Januar 2010 13:00:36 schrieben Sie:
> > Is there a way to tell how much memory and object takes?
>
> Yes, please have a look at class INTERNAL. It has some queries
>like e.g. deep_physical_size(o) which will give the total size
>of object "o".




brucemount

unread,
Sep 8, 2015, 2:48:52 AM9/8/15
to eiffel_...@yahoogroups.com

Martin (others):

I used 'deep_physical_size' from INTERNAL which (according to the comment in the code) returns "Space occupied by `object' and its children in bytes" and got this surprising result:

CHARACTER_8 size: 24
INTEGER_8 size: 24
INTEGER_32 size: 24
INTEGER_64 size: 24
NATURAL_8 size: 24
NATURAL_16 size: 24
NATURAL_32 size: 24
NATURAL_64 size: 24

Is it really true that expanded types take 24 bytes of storage, no matter what the size? It don't understand how a NATURAL_8 and a NATURAL_64 can take the same storage size.

Am I doing something wrong?

--Bruce
======================================

brucemount

unread,
Sep 8, 2015, 2:48:52 AM9/8/15
to eiffel_...@yahoogroups.com

> It don't understand how a NATURAL_8 and a NATURAL_64
> can take the same storage size.

...I guess I should have added that I also didn't expect a single-byte NATURAL_8 to take TWENTY FOUR times more storage than I expected at 24 bytes, which is why I wonder if I'm doing something wrong.

--Bruce
Reply all
Reply to author
Forward
0 new messages