Home
Support

Knowledge Base

BSPs and drivers
Community resources
Product documentation
Questions?
Contact us

How to get free memory value?
 
________________________________________________________________________

Applicable Environment
________________________________________________________________________
  • Topic: How to get free memory value?
  • SDP: 6.5.0
  • Target: Any supported target
________________________________________________________________________

Recommendation
________________________________________________________________________

use pidin utility like:

# pidin info
CPU:X86 Release:6.5.0 FreeMem:775Mb/1023Mb BootTime:Jul 26 13:28:09 CEST 2010
Processes: 76, Threads: 156
Processor1: 1586 Intel ?86 F15M2S7 2411MHz FPU
or :

# cat getfreemem.c
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <err.h>
#include <sys/stat.h>
#include <sys/types.h>


int main( int argc, char *argv[] )
{
struct stat statbuf;
paddr_t freemem;

stat( "/proc", &statbuf );
freemem = (paddr_t)statbuf.st_size;
printf( "Free memory: %d bytes\n", freemem );
printf( "Free memory: %d KB\n", freemem / 1024 );
printf( "Free memory: %d MB\n", freemem / ( 1024 * 1024 ) );

return 0;
}
# make getfreemem
cc getfreemem.c -o getfreemem
# ./getfreemem
Free memory: 804982784 bytes
Free memory: 786116 KB
Free memory: 767 MB
#

________________________________________________________________________
NOTE: This entry has been validated against the SDP version listed above. Use caution when considering this advice for any other SDP version. For supported releases, please reach out to QNX Technical Support if you have any questions/concerns.
________________________________________________________________________


Related Attachments
 None Found





Please contact us with your questions or concerns.