[VPM] - data structures, performance and memory
jeremygwa at hotmail.com
Fri Nov 10 17:30:02 PST 2006
Thank-you for your reply.
the "hundred" records example was not a good one, I mean very large records
put together in a very large array.....(in the thousands).
what are the memory sizes for scalars,hashes,single-dim arrays,double-dim
arrays, array of anon-hashes -etc. how can i use as little memory as
possible, and how can i search these very large arrays efficiently.
Some pointers would be great, I don't need any examples.
are elements on a array, of variant data-type...does this general type
consume more memory than if the type is explicitly defined, if so, how can
I explicitly define the type, eg. int,string,bool in perl terms etc.
can operations on very large arrays eat up more memory, in execution?
how can I control perl's allocation of memory.
I am using Activestate perl 5.8 on a win32 host.
Thank in advance for your help.
> >project 2: I am working on a project where I need to store data in
> >What are the memory requirements of certain structures eg.
> >of anon hashes,array of packed data,array of strings, array of objects
> >suppose I have a hundred records (structures) holding eg.
> >etc. what is the best way of storing this data live in memory for a long
> >period time, for performance and efficiency.
> >An array of anon hashes is pretty, but may not be the best for
> >and mem usage...am i right? Considering this, how can I store records
> >elements that can be of different record types, saving the most amount of
> >memory as possible......can I do this with pack and unpack, I am not
> >familiar with this, but do you think s more efficient, than an array of
> >element delimited strings? or what if each record is an instantiated
> >with properties?
> >Thanks in advance for your advice and help.
> > -Jeremy A.
>I think you may be getting into a "premature optimization" matter.
>If you have only a hundred records of eg age,name,address, those will
>all take up maybe 1 kilobyte at most of memory, which is negligible.
>Don't bother fussing about memory unless you're storing tens of
>thousands or more of such records, or you're working on an embedded
>system. Just do whatever is easiest to program, as programmer
>efficiency is usually more important than any other kind. Use hashes
>if you're looking data up directly, such as by the person's name, and
>arrays only when you plan to go through them sequentially. Or you
>can include multiple references to the same data structures if you
>-- Darren Duncan
>Victoria-pm mailing list
>Victoria-pm at pm.org
Ready for the world's first international mobile film festival celebrating
the creative potential of today's youth? Check out Mobile Jam Fest for your
a chance to WIN $10,000! www.mobilejamfest.com
More information about the Victoria-pm