www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/05/11:45:38

From: a AT b DOT com (Hbar)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Amount of Memory used by a djgpp program.
Date: Wed, 05 Jul 2000 15:27:06 GMT
Organization: The Hebrew University of Jerusalem
Lines: 39
Message-ID: <396352ca.29983468@news.huji.ac.il>
References: <395f5aee DOT 3516835 AT news DOT huji DOT ac DOT il> <200007021626 DOT TAA08137 AT alpha DOT netvision DOT net DOT il>
NNTP-Posting-Host: ufo1.weizmann.ac.il
Mime-Version: 1.0
X-Trace: news.huji.ac.il 962810829 16311 132.77.40.26 (5 Jul 2000 15:27:09 GMT)
X-Complaints-To: usenet AT news DOT huji DOT ac DOT il
NNTP-Posting-Date: 5 Jul 2000 15:27:09 GMT
X-Newsreader: Forte Agent 1.5/32.451
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019