home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 9026 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  2.0 KB

  1. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!wupost!sdd.hp.com!swrinde!elroy.jpl.nasa.gov!news.claremont.edu!ucivax!megatek!hollen
  2. From: hollen@megatek.UUCP (Dion Hollenbeck)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Re: New and farcoreleft()
  5. Message-ID: <HOLLEN.92Sep3114500@peg.megatek.UUCP>
  6. Date: 3 Sep 92 19:45:00 GMT
  7. References: <1992Sep3.134102.17553@news2.cis.umn.edu>
  8. Sender: hollen@megatek.com (Dion Hollenbeck)
  9. Organization: Megatek Corporation, San Diego, California
  10. Lines: 37
  11. In-Reply-To: wright@epx.cis.umn.edu's message of Thu, 3 Sep 1992 13: 41:02 GMT
  12.  
  13. In article <1992Sep3.134102.17553@news2.cis.umn.edu>
  14. wright@epx.cis.umn.edu (Mark Wright) writes:
  15.  
  16. Mark>      In a C++ program I've been writing, strategically placed
  17. Mark>   farcoreleft()'s seem to be saying that my objects are not being
  18. Mark>   de-allocated correctly when I 'destroy' them.  Should I worry about
  19. Mark>   this, or is farcoreleft() designed for use with malloc()?  If so,
  20. Mark>   is there a C++ function which will tell me how much mem. I have
  21. Mark>   left?  I'm using Borland C++ v3.1.
  22.  
  23. Yes it is designed for use with malloc().  It is probably working
  24. correctly, you probably do not know how it is working.
  25.  
  26. Start out with 1000 bytes to allocate
  27.  
  28.     a = malloc(10)
  29.     b = malloc(10)
  30.     farcoreleft() will return 980
  31.     free(a)
  32.     farcoreleft() will return 980
  33.     free(b)
  34.     farcoreleft() will return 1000
  35.  
  36. farcoreleft() will return the amount of memory between the last amount
  37. of memory allocated and the top of memory, therefore not accounting
  38. for the memory returned to the pool when you free chunks not at the
  39. end of the pool.  farcoreleft() will eventually return the "base"
  40. value seen before any allocations were made, once you have freed
  41. everything allocated.
  42.  
  43. If this does not explain the behavior you are seeing, then maybe there
  44. is something wrong.
  45.  
  46. -- 
  47. Dion Hollenbeck       UUCP: {uunet, ucsd, sun}!megatek!hollen
  48.                       INTERNET:            hollen@megatek.com
  49. Megatek Corporation  9645 Scranton Rd.  San Diego, Ca.  92121
  50.