Max Memory in Perl and How to reuse gabage?

G

Great Deals

If I use
@lines = <INPUT>
to read a file, to avoid the comlicated method from PerlFaq, what is
the max size of the file @lines = <INPUT> can read? Upto the max of
the physical memory+swep? Will my or local automatically do gabarage
collection/release?

If I use great deals of memory in @ and %, and I really want to
allocate more memory again in the script, should I use undef the @ and
% to release the memory?

Another question is how large can a $ be in term of size. How large an
interger perl can handle. I know there is some limit of the biggest
interger in C, then I will have a long interger in C.
 
J

Jürgen Exner

Great said:
If I use
@lines = <INPUT>
to read a file,

In most cases it is not a good idea to store the whole file in memory unless
you cannot process the file line by line. Most applications can process a
file line by line or can easily be rewritten to process a file line by line.
to avoid the comlicated method from PerlFaq, what is

What complicated method? No idea what you are talking about.
the max size of the file @lines = <INPUT> can read? Upto the size of
the physical memory+swep?

The maximum size of a Perl array is limited by the available amount of
virtual memory and maximum index size. Depending on your OS, 32 versus 64
bit, and your version of Perl that should be somewhere in the GB or TB
range.
But please be aware that due to the way Perl represents scalars a string
with 100 characters takes up quite a bit more space than just 100 bytes.
Will my or local automatically do gabarage
collection/release?

Collect: yes.
Release to the OS: AFAIK no

[...]
Another question is how large can a $ be in term of size.

Only limited by your virtual memory and the 32 resp. 64 bit index boundary.
How large an
interger perl can handle. I know there is some limit of the biggest
interger in C, then I will have a long interger in C.

You can always use Math::BigInt

jue
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(e-mail address removed) (Great Deals) wrote in
If I use
@lines = <INPUT>
to read a file, to avoid the comlicated method from PerlFaq,

Do you really consider

@lines = <INPUT>;
foreach (@lines)

to be less complicated than

while (<INPUT>)

?

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP3ftxmPeouIeTNHoEQK32gCdGjTw9y+IHhq372KVUbqnYH0cYbsAoLNy
o9cwtbLsCzzITLGEJ84Xtsct
=pChz
-----END PGP SIGNATURE-----
 
C

Chris Richmond - MD6-FDC ~

The maximum size of a Perl array is limited by the available amount of
virtual memory and maximum index size. Depending on your OS, 32 versus 64
bit, and your version of Perl that should be somewhere in the GB or TB
range.

I will contend that this isn't necessarily true. At least on
Solaris, we had to make a special effort to enable more than a
1GB process size. The same application on AIX keeled over when
that limit was hit. Same thing on linux when I tried.
Only limited by your virtual memory and the 32 resp. 64 bit index boundary.

Are you positive? We were using perl5.00404 at the time.
What actual perl process sizes have you dealt with?

Thx, Chris
 
J

Jürgen Exner

Chris said:
I will contend that this isn't necessarily true. At least on
Solaris, we had to make a special effort to enable more than a
1GB process size. The same application on AIX keeled over when
that limit was hit. Same thing on linux when I tried.


Are you positive? We were using perl5.00404 at the time.
What actual perl process sizes have you dealt with?

You are right, there is of course the additional limit as imposed by the OS.
And of course the admin can even set that limit pretty low for some users if
he wishes so.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top