From 33c0573598ddd0714b59ac6e1ec4c252a3eff2ba Mon Sep 17 00:00:00 2001 From: George Koehler Date: Wed, 14 Nov 2018 16:13:54 -0500 Subject: [PATCH] Remove code to calculate memory usage with sbrk(). In many systems, malloc() can allocate outside the brk area. The calculation with sbrk() misses those allocations. When LLgen or ncgg reported the memory usage, the value was probably too low. --- util/LLgen/src/main.c | 5 ----- util/ncgg/main.c | 4 ---- util/ncgg/output.c | 2 -- 3 files changed, 11 deletions(-) diff --git a/util/LLgen/src/main.c b/util/LLgen/src/main.c index 1bd31aa46..11a5c26a8 100644 --- a/util/LLgen/src/main.c +++ b/util/LLgen/src/main.c @@ -37,12 +37,10 @@ extern fatal(); extern comfatal(); extern copyfile(); extern void install(); -extern char *sbrk(); main(argc,argv) register string argv[]; { register string arg; string libpath(); - char *beg_sbrk = 0; /* Initialize */ @@ -129,8 +127,6 @@ main(argc,argv) register string argv[]; { argc--; } - if (verbose) beg_sbrk = sbrk(0); - #ifdef NON_CORRECTING if ((subpars_sim) && (!non_corr)) { fprintf(stderr,"option -s illegal without -n, turned off\n"); @@ -206,7 +202,6 @@ main(argc,argv) register string argv[]; { fprintf(stderr, "number of tokens: %d\n", ntokens); fprintf(stderr, "number of term structures: %d\n", nterms); fprintf(stderr, "number of alternation structures: %d\n", nalts); - fprintf(stderr, "total memory used: %ld\n", (long)(sbrk(0) - beg_sbrk)); } exit(0); } diff --git a/util/ncgg/main.c b/util/ncgg/main.c index 330e08c98..dff1f4d54 100644 --- a/util/ncgg/main.c +++ b/util/ncgg/main.c @@ -11,8 +11,6 @@ static char rcsid[]= "$Id$"; #include "extern.h" char *filename; -char *beg_sbrk; -extern char *sbrk(); main(argc,argv) char **argv; { extern int nerrors; @@ -20,8 +18,6 @@ main(argc,argv) char **argv; { extern int tabledebug; extern int verbose; - beg_sbrk = sbrk(0); - while (argc >1 && argv[1][0]=='-') { switch(argv[1][1]) { case 'c': diff --git a/util/ncgg/output.c b/util/ncgg/output.c index 02e3162f7..7d85b9179 100644 --- a/util/ncgg/output.c +++ b/util/ncgg/output.c @@ -902,7 +902,6 @@ used(resource,use,max) char *resource; { } statistics() { - extern char *beg_sbrk,*sbrk(); extern int nnodes, maxempatlen,maxrule; used("Registers",nregs,MAXREGS); @@ -926,5 +925,4 @@ statistics() { used("Pat bytes",npatbytes+1,MAXPATBYTES); if (tabledebug) used("Source lines",maxline,MAXSOURCELINES); - fprintf(stderr,"%ldK heap used\n",((long) (sbrk(0)-beg_sbrk+1023))/1024); }