From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,INVALID_MSGID, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,123c40d62c632159 X-Google-Attributes: gid103376,public From: aaro@iki.fi (Aaro Koskinen) Subject: Re: Stack based allocation vs. Dynamic allocation Date: 2000/05/31 Message-ID: #1/1 X-Deja-AN: 629452845 References: X-Complaints-To: usenet@news.helsinki.fi X-Trace: oravannahka.helsinki.fi 959779303 1931 128.214.205.10 (31 May 2000 13:21:43 GMT) Organization: University of Helsinki NNTP-Posting-Date: 31 May 2000 13:21:43 GMT Newsgroups: comp.lang.ada Date: 2000-05-31T13:21:43+00:00 List-Id: gisle@struts.ii.uib.no (Gisle S�lensminde) writes: > gisle@gekko:116> time heap > Time: 0:53.92 real 31.250 user 12.190 sys 80.5% > > gisle@gekko:120> time stack > Time: 0:11.02 real 10.490 user 0.030 sys 95.4% > > The stack program was 3 times faster if you consider user times. > In my tests the system time used was always at least 11 seconds, > while the stack program never used more than 0.05 seconds. The > system have to work harder when using heap allocation, which makes > the heap program run in only 1/4th of the time of the stack program. The huge amount of used system time is interesting, since the allocated data is always of the same size - there shouldn't be any need for another system call after the first "new". Unless the "free" releases the memory back to the operating system. (Most of C library implementations I've seen do not usually shrunk the process' heap on free()). -- Aaro Koskinen, aaro@iki.fi, http://www.iki.fi/aaro