home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!sol.ctr.columbia.edu!eff!world!siegel
- From: siegel@world.std.com (Rich Siegel)
- Subject: Re: Why is new(p) so slow in THINK Pascal?
- Message-ID: <C0JIxw.3KG@world.std.com>
- Keywords: THINK Pascal, dynamic variables
- Organization: GCC Technologies
- References: <4940@svin09.info.win.tue.nl>
- Date: Fri, 8 Jan 1993 14:58:43 GMT
- Lines: 25
-
- In article <4940@svin09.info.win.tue.nl> wstomv@win.tue.nl writes:
- >In order to compare some sorting procedures for linked lists (implemented
- >in THINK Pascal) I applied them to random lists of varying lengths.
- >It turns out that the procedure new(p), which allocates storage for
- >a dynamic variable pointed to by p, is extremely slow. Does anyone
- >know why? New-ing a thousand items takes a noticeable time, new-ing
- >10,000 items takes minutes (on my lowly SE/30).
-
- New() for pointer variables simply calls NewPtr. With that many small
- blocks, you're overloading the Memory Manager, which has to find space
- low in the heap each time you call New. Under the circumstances, you
- might want to think about an alternative storage strategy.
-
- Starting with an initial free list of pointer blocks is OK, but you're
- still hammering the Memory Manager - you might want to think about
- allocating a single large chunk and using pieces of it as you need them.
-
- R.
-
-
- --
- -----------------------------------------------------------------------
- Rich Siegel Internet: siegel@world.std.com
- Senior Software Engineer
- GCC Technologies
-