Real memory size of an array

View: New views
5 Messages — Rating Filter:   Alert me  

Real memory size of an array

by Bertrand LUPART :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,


I'm looking for a way to know the real memory size (eg bytes) for an
array but can't find any. Is there a simple way to do that?

My goal is to do some profiling in an application that makes databases
access and seems to sometime query too much data. Maybe there's a way to
know how much data the MySQL server returned to query()?

Thank you,

--
Bertrand LUPART

http://bertrand.gotpike.org/


Real memory size of an array

by Mirar @ Pike importmöte för mailinglistan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Isn't the problem that while an array is always around
sizeof(svalue)*n (usually around 16*n) bytes, the data contained in it
can't really be measured well since Pike has shared strings and
similar?


Parent Message unknown Re: Real memory size of an array

by Bertrand LUPART :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mirar @ Pike  importmöte för mailinglistan <6341@...>
wrote:

> Isn't the problem that while an array is always around
> sizeof(svalue)*n (usually around 16*n) bytes, the data contained in it
> can't really be measured well since Pike has shared strings and
> similar?

Maybe true.

Just doing a little function looping over elements which counts string
sizes. I guess there's something more clever to do.


--
Bertrand LUPART

http://bertrand.gotpike.org/


Re: Real memory size of an array

by Martin Stjernholm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

bertrand.lupart@... (Bertrand LUPART) wrote:

> I'm looking for a way to know the real memory size (eg bytes) for an
> array but can't find any. Is there a simple way to do that?

Take a look at Pike.count_memory (new in 7.8).


Re: Real memory size of an array

by Bertrand LUPART :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Martin Stjernholm <mast@...> wrote:

> bertrand.lupart@... (Bertrand LUPART) wrote:
>
> > I'm looking for a way to know the real memory size (eg bytes) for an
> > array but can't find any. Is there a simple way to do that?
>
> Take a look at Pike.count_memory (new in 7.8).

https://extranet.roxen.com/support/docs/refdoc-5.0/ex/predef_3A_3A/Pike/
count_memory.html

> array a = ({ ([ "foo":random_string(1024), "bar":random_string(2048) ]) });
> Pike.count_memory(0,a);
> (1) Result: 3538

Nice, thank you.

--
Bertrand LUPART

http://bertrand.gotpike.org/