home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6961 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  1.1 KB

  1. Path: sparky!uunet!know!mips2!cass.ma02.bull.com!think.com!sdd.hp.com!cs.utexas.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!rutgers!rwja!majidi
  2. From: majidi@rwja.umdnj.edu (Masoud Majidi)
  3. Newsgroups: comp.lang.perl
  4. Subject: push/pop and memory management
  5. Message-ID: <1682@rwja.umdnj.edu>
  6. Date: 12 Nov 92 19:48:04 GMT
  7. Organization: Robert Wood Johnson Medical School, Piscataway NJ
  8. Lines: 22
  9.  
  10. Dear netters,
  11.  
  12. I have a small perl code whose memory requirement was getting out of
  13. hand. After studying the code for a while I am convinced that push/pop
  14. is not working the way I expected. To prove the point I wrote a small
  15. program which does nothing but pushing and popping from an array:
  16.  
  17. for (1 .. 10000)
  18. {
  19.     push (@ary, 13);
  20.     pop (@ary);
  21. }
  22.  
  23. And I checked the memory allocated to this code before and after the
  24. loop. To my surprise there was more 2.5 Meg difference. Even if the pop
  25. calls don't free the space I still don't understand how pushing 10,000
  26. entries can increase the space by 2.5 Megs. I would appreciate it very
  27. much if somebody would explain the above behavior.
  28.  
  29. Thanks in advance,
  30.  
  31. Masoud Majidi (majidi@umdnj.edu)
  32.