Article View: comp.os.msdos.programmer
Article #1259Re: New and farcoreleft()
From: Dion Hollenbeck
Date: Thu, 03 Sep 1992 19:45
Date: Thu, 03 Sep 1992 19:45
37 lines
2087 bytes
2087 bytes
In article <1992Sep3.134102.17553@news2.cis.umn.edu>
wright@epx.cis.umn.edu (Mark Wright) writes:
Mark> In a C++ program I've been writing, strategically placed
Mark> farcoreleft()'s seem to be saying that my objects are not being
Mark> de-allocated correctly when I 'destroy' them. Should I worry about
Mark> this, or is farcoreleft() designed for use with malloc()? If so,
Mark> is there a C++ function which will tell me how much mem. I have
Mark> left? I'm using Borland C++ v3.1.
Yes it is designed for use with malloc(). It is probably working
correctly, you probably do not know how it is working.
Start out with 1000 bytes to allocate
a = malloc(10)
b = malloc(10)
farcoreleft() will return 980
free(a)
farcoreleft() will return 980
free(b)
farcoreleft() will return 1000
farcoreleft() will return the amount of memory between the last amount
of memory allocated and the top of memory, therefore not accounting
for the memory returned to the pool when you free chunks not at the
end of the pool. farcoreleft() will eventually return the "base"
value seen before any allocations were made, once you have freed
everything allocated.
If this does not explain the behavior you are seeing, then maybe there
is something wrong.
--
Dion Hollenbeck UUCP: {uunet, ucsd, sun}!megatek!hollen
INTERNET: hollen@megatek.com
Megatek Corporation 9645 Scranton Rd. San Diego, Ca. 92121
Technical Details
Message-ID:
<HOLLEN.92Sep3114500@peg.megatek.UUCP>Path:
arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!wupost!sdd.hp.com!swrinde!elroy.jpl.nasa.gov!news.claremont.edu!ucivax!megatek!hollenReferences:
<1992Sep3.134102.17553@news2.cis.umn.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!darwin.sura.net!wupost!sdd.hp.com!swrinde!elroy.jpl.nasa.gov!news.claremont.edu!ucivax!megatek!hollen From: hollen@megatek.UUCP (Dion Hollenbeck) Newsgroups: comp.os.msdos.programmer Subject: Re: New and farcoreleft() Message-ID: <HOLLEN.92Sep3114500@peg.megatek.UUCP> Date: 3 Sep 92 19:45:00 GMT References: <1992Sep3.134102.17553@news2.cis.umn.edu> Sender: hollen@megatek.com (Dion Hollenbeck) Organization: Megatek Corporation, San Diego, California Lines: 37 In-Reply-To: wright@epx.cis.umn.edu's message of Thu, 3 Sep 1992 13: 41:02 GMT