Article View: gnu.gcc.help
Article #46659Getting available memory size
From: Pete Golda
Date: Wed, 02 Nov 1994 14:34
Date: Wed, 02 Nov 1994 14:34
27 lines
1606 bytes
1606 bytes
Hi, I'm working on some large data sets (+100Meg), and GNUC has solved most of my problems in that I can allocate enough memory to hold the entire file. However, when swapping to disk begins, the entire process infinitely slows down. Knowing that my PC has 32meg of RAM, and that about 2 meg is already used, I now allocate a +/- 28meg array, block read 28meg from file and process. Once that's finished I write to file and read in the next 28meg block. My question: Is there any way to find out the size of the available free memory (including base and extended and all that) ?? I want to automate this process of memory allocation such as: FreeMem = FindAllFreeMemory(); FreeMem *= 0.9 /* Leave 10% of memory for safety */ char *array = malloc( (long) FreeMem ); so that the programs can run on machines with any amount of RAM, and automatically detect how large the array may be so as to aviod disk swapping. Thanx in advance, Pete.
Technical Details
Message-ID:
<PGOLDA.17.783786893@eleceng.uct.ac.za>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!gatech!howland.reston.ans.net!quagga.ru.ac.za!ucthpx!eleceng.uct.ac.za!PGOLDAShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,189da423332f2509,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1994-11-02 06:34:53 PST Path: arc1-ca.pugleaf.net!nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!gatech!howland.reston.ans.net!quagga.ru.ac.za!ucthpx!eleceng.uct.ac.za!PGOLDA From: PGOLDA@eleceng.uct.ac.za (Pete Golda) Newsgroups: gnu.gcc.help Subject: Getting available memory size Date: Wed, 2 Nov 1994 14:34:53 GMT Organization: University of Cape Town Lines: 27 Distribution: world Message-ID: <PGOLDA.17.783786893@eleceng.uct.ac.za> NNTP-Posting-Host: 137.158.131.55