Mail Archives: djgpp/2000/07/05/11:45:38
Thnx, I'm using this method, but sometimes I'm getting proper numbers
and sometimes not. Am I casting wrong? Should the *mem pointers be
void? This is my code:
char *memi,*memf;
memi=(char *)sbrk(0);
//my program
memf=(char *)sbrk(0);
printf("\nTotal memory used %dKb\n",((unsigned
long)(memf-memi))/1024);
Thank you again
Hagai
On Sun, 02 Jul 2000 19:28:30 +0200, "Eli Zaretskii"
<eliz AT is DOT elta DOT co DOT il> wrote:
>> From: a AT b DOT com (Hbar)
>> Newsgroups: comp.os.msdos.djgpp
>> Date: Sun, 02 Jul 2000 15:13:57 GMT
>>
>> Do you know of a way to discover the amount of memory that is used by
>> a program? Anything like 'redir' which will tell me the peak usage of
>> memory?
>
>It's not easy, unfortunately. You might get some insight into the
>reasons why isn't this easy if you read Chapter 15 of the DJGPP FAQ
>list.
>
>One possibility to estimate the maximum memory usage is to call
>sbrk(0) near the beginning of the `main' function and right before
>you exit; the difference between the two numbers will give an
>approximation of memory allocated dynamically.
>
>If that is not good enough, perhaps you could tell more about why do
>you need to know the maximum memory usage.
- Raw text -