Re: 'out of memory' errors



tom arnall wrote:

i am trying to us a perl application that handles large files (.5GB) in scalar
variables. when i try to 'slurp' one of these files into a variable
(e.g., '$_ = `cat filename`) i get an out of memory error.

You should consider alternative solutions, like processing files line by
line for example. It highly depends on what you are trying to achieve,
but loading half a gig into memory is not something you should do
without having a very good reason for doing so.

is there not some way to get linux to use swap space when physical memory is
exceeded?

It does that by default, assuming you do have swap partitions or files
available. Note that this can be slow, and I assume this is what you
described as a "freeze".

There are many tunable Linux virtual memory parameters you can set via
sysctl interface. You can get a list of them with "sysctl -a | grep vm".
The most useful one is vm.swappiness. You can set it to a number from 0
to 100. 0 means "try not to use swap at all" and 100 - "swap as much as
possible" with all other values in between. You can set it (and other
sysctl options) like this:

# sysctl -w vm.swappiness=60

To preserve settings on reboots, edit "/etc/sysctl.conf".


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: SYN Attacks - how i cant stop it
    ... "sysctl: unknown oid...." ... Then use stateful inspection and dynamic rules for the ... > rest of the wall. ... To unsubscribe, ...
    (FreeBSD-Security)
  • Re: SYN Attacks - how i cant stop it
    ... "sysctl: unknown oid...." ... Then use stateful inspection and dynamic rules for the ... > rest of the wall. ... To unsubscribe, ...
    (freebsd-questions)
  • RE: kswapd issue
    ... What I was missing earlier was "did not run sysctl -p" after changing ... damage you may sustain as a result of any virus in this e-mail. ... Infosys reserves the right to monitor and review the content ... unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe ...
    (RedHat)
  • Re: Problem Tuning Maxsockets
    ... > I am trying to alter the number of maxsockets allocated from the default ... > operation via sysctl I'm informed the oid is read ... To unsubscribe, ...
    (freebsd-questions)
  • Re: Routing RH 8
    ... General Red Hat Linux discussion list ... to 1 and then run sysctl manually to set it for the active session ... unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe ...
    (RedHat)