how many bytes per $scalar, $ref2something and the like?

From: Ralf Wahner (Ralf.Wahner_at_iwr.uni-heidelberg.de)
Date: 05/24/04


Date: 24 May 2004 01:41:42 -0700

Dear Masters of Perl

I've been searching for a long time for an answer on the question how much
memory the data structures of Perl require. Usually, say, a floating point
number of double precision gets eight bytes and an integer four bytes.
So far I couldn't find out, how many bytes Perl takes to store

 - a scalar $a
 - a reference to a scalar, array, hash or subroutine
 
Since arrays and hashes consist of scalars themselves, this should be
sufficient for estimating the memory usage of arbitrary data structures.

Background: I'm writing my diploma thesis on numerical mathematics. At the
moment I'm finishing a grid generator. Since the program needs a vast amount
of data in order to write the grid files the memory usage grows very fast
for huge grids. It appears that my program either produces a memory leak or
actually runs out of memory. In order to find the reason it would be a great
help to estimate the memory usage of the data structures. Unfortunately, I
couldn't find a hint on how much memory Perl allocates for its data types.

Any tip is gratefully appreciated. Thanks in advance,

Ralf



Relevant Pages

  • Re: how many bytes per $scalar, $ref2something and the like?
    ... Perl uses your C compiler's defaults for most of this - but - maybe you've ... of "memory" to play with, just the same as using real memory. ... > sufficient for estimating the memory usage of arbitrary data structures. ... > moment I'm finishing a grid generator. ...
    (comp.lang.perl)
  • Re: Perl takes a lot of memory when you just require a file
    ... parsing in perl. ... If I do populate data in form of 3-D array is perl memory requirement ... file '' while I am populating no data structures. ...
    (comp.lang.perl.misc)
  • Re: performance and memory usage.
    ... You're still ignoring the overhead for memory ... allocation data structures. ... Dynamic memory management is not magical in C. ... purpose hash table written in C. ...
    (comp.lang.java.programmer)
  • Assigning data structures to certain memory locations during porting
    ... I'm new to embedded programming. ... I'm trying to dynamically allocate data structures and uniquely map ... target machine with a scratch pad, a DRAM, and a Flash Memory. ...
    (comp.arch.embedded)
  • Re: Newbie completely confused
    ... Your program uses quite a bit of memory. ... And really, reading 30MB files should not be such a problem, right? ... 'del LINES' deletes the lines that are read from the file, but not all of your data structures that you created out of them. ... The python code loads a module written in C++ and some of the member variables actually point to C++ objects created dynamically, so one actually has to call their destructors before unbinding the python var. ...
    (comp.lang.python)