home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20989 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.6 KB  |  37 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. 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
  3. From: siegel@world.std.com (Rich Siegel)
  4. Subject: Re: Why is new(p) so slow in THINK Pascal?
  5. Message-ID: <C0JIxw.3KG@world.std.com>
  6. Keywords: THINK Pascal, dynamic variables
  7. Organization: GCC Technologies
  8. References: <4940@svin09.info.win.tue.nl>
  9. Date: Fri, 8 Jan 1993 14:58:43 GMT
  10. Lines: 25
  11.  
  12. In article <4940@svin09.info.win.tue.nl> wstomv@win.tue.nl writes:
  13. >In order to compare some sorting procedures for linked lists (implemented
  14. >in THINK Pascal) I applied them to random lists of varying lengths.
  15. >It turns out that the procedure new(p), which allocates storage for
  16. >a dynamic variable pointed to by p, is extremely slow.  Does anyone
  17. >know why?  New-ing a thousand items takes a noticeable time, new-ing
  18. >10,000 items takes minutes (on my lowly SE/30).
  19.  
  20. New() for pointer variables simply calls NewPtr. With that many small
  21. blocks, you're overloading the Memory Manager, which has to find space
  22. low in the heap each time you call New. Under the circumstances, you
  23. might want to think about an alternative storage strategy.
  24.  
  25. Starting with an initial free list of pointer blocks is OK, but you're
  26. still hammering the Memory Manager - you might want to think about
  27. allocating a single large chunk and using pieces of it as you need them.
  28.  
  29. R.
  30.  
  31.  
  32. -- 
  33. -----------------------------------------------------------------------
  34. Rich Siegel                              Internet: siegel@world.std.com
  35. Senior Software Engineer
  36. GCC Technologies
  37.