home *** CD-ROM | disk | FTP | other *** search
- 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
- From: majidi@rwja.umdnj.edu (Masoud Majidi)
- Newsgroups: comp.lang.perl
- Subject: push/pop and memory management
- Message-ID: <1682@rwja.umdnj.edu>
- Date: 12 Nov 92 19:48:04 GMT
- Organization: Robert Wood Johnson Medical School, Piscataway NJ
- Lines: 22
-
- Dear netters,
-
- I have a small perl code whose memory requirement was getting out of
- hand. After studying the code for a while I am convinced that push/pop
- is not working the way I expected. To prove the point I wrote a small
- program which does nothing but pushing and popping from an array:
-
- for (1 .. 10000)
- {
- push (@ary, 13);
- pop (@ary);
- }
-
- And I checked the memory allocated to this code before and after the
- loop. To my surprise there was more 2.5 Meg difference. Even if the pop
- calls don't free the space I still don't understand how pushing 10,000
- entries can increase the space by 2.5 Megs. I would appreciate it very
- much if somebody would explain the above behavior.
-
- Thanks in advance,
-
- Masoud Majidi (majidi@umdnj.edu)
-