Get A Heap Informations.


rupaus

Still Fresh
Joined
Jan 29, 2007
Messages
2
Hello~

I write a code for see memory status.

Here my code
Code:
FILE			*Memory;
unsigned long	dwMemoryTotalSize;
unsigned long	dwMemoryUsedSize;
unsigned long	dwMemoryFreeSize;

Memory = fopen ( "/proc/meminfo", "r" );
if ( NULL != Memory )
{
	fscanf ( Memory, "%ld %ld %ld", &dwMemoryTotalSize, &dwMemoryUsedSize, &dwMemoryFreeSize );
	fclose ( Memory );

	printf ( "Total = %ld, Used = %ld, Free = %ld\r\n", dwMemoryTotalSize, dwMemoryUsedSize, dwMemoryFreeSize );
}

Run this code result is strange.
This is my first linux applications so i need help.

Thanks for any help!!!
 
someone gives tip to me.

use sysinfo () function.

I changed my code.

Code:
struct sysinfo info;

if ( 0 == sysinfo ( &info ) )
{
	printf ( "Free : %ld Shared : %ld Buffer : %ld  @@@ %s\r\n", info.freeram, info.sharedram, info.bufferram, szFunctionName );
}

It's good working.

Thanks.
 
Back
Top