Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How can I make my program occupying a lot of memory (sic!)?

by BrowserUk (Pope)
on Nov 03, 2012 at 20:25 UTC ( #1002139=note: print w/ replies, xml ) Need Help??


in reply to How can I make my program occupying a lot of memory (sic!)?

it would lead to elseone 1G of memory occupied.

??

Could anyone tell me either how to make a program occupy a lot of memory

Easy:

my $mem = chr(0); $mem x= 1024**3; ## 1 GiB.
or answer a question: How much resources would be occupied totally if I run following code from a program that occupies, say, 1G of memory itself? ]

Try it :)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


Comment on Re: How can I make my program occupying a lot of memory (sic!)?
Download Code
Re^2: How can I make my program occupying a lot of memory (sic!)?
by Doctrin (Beadle) on Nov 03, 2012 at 20:38 UTC
    Thanks a lot! This is what I've needed. I tried to launch your code, then fork, and it didn't take much more memory. I just thought that fork() call would duplicate the memory related to the parent process, but it didn't as it seems...
Re^2: How can I make my program occupying a lot of memory (sic!)?
by Doctrin (Beadle) on Nov 03, 2012 at 20:49 UTC
    Hmm, no, I've made a mistake. It uses an extra 1 GiB as free -m says. Anyways, thanks for the code :) Now I know that I cannot execute fork()-s from heavy programs.
      It uses an extra 1 GiB as free -m says.

      I don't use *nix, but I think that the tool you are using is giving you bad info.

      AFAIK: That memory will not be cloned unless the forked child accesses it.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      RIP Neil Armstrong

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-12-21 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (105 votes), past polls