hello
how can i know my memory space wich is available,
in C code.
like with the utilitie " sin " with option " info "
thanks
hello
how can i know my memory space wich is available,
in C code.
like with the utilitie " sin " with option " info "
thanks
crib wrote:
how can i know my memory space wich is available,
in C code.
The functions below (or something like them) came from
the QNX migration library and are for this purpose.
regards
William
#include <stdio.h>
#include <fcntl.h>
#include <sys/syspage.h>
// This comes from the QNX->Neutrino migration library
static void get_total_mem( char * buffer, size_t size )
{
char *str = SYSPAGE_ENTRY(strings)->data;
struct asinfo_entry *as = SYSPAGE_ENTRY(asinfo);
int total = 0;
unsigned num;
for(num = _syspage_ptr->asinfo.entry_size / sizeof(as); num > 0;
–num) {
if(strcmp(&str[as->name], “ram”) == 0) {
total += as->end - as->start + 1;
}
++as;
}
snprintf( buffer, size, “%3d”, total / (10241024));
} // get_total_mem
// This comes from the QNX->Neutrino migration library
static void get_free_mem( char * buffer, size_t size )
{
struct stat st;
int rval = 0;
if (stat( “/proc”, &st) == 0)
rval = st.st_size;
snprintf( buffer, size, “%3d”, rval / (1024*1024));
} // get_free_mem
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
int main () {
struct stat buf;
if ( stat( “/proc”, &buf ) == -1) {
perror (“stat” );
return EXIT_FAILURE;
} else {
printf (“Free memory: %d Kbytes\n”, buf.st_size/1000);
return EXIT_SUCCESS;
}
}
crib wrote:
hello
how can i know my memory space wich is available,
in C code.like with the utilitie " sin " with option " info "
thanks
Does anyone know how to view the system virtual memory available and used?
Just like sin info in version 4.2
“BoB Macaulay” <bnrbob@nortelnetworks.com> wrote in message
news:3EAEC587.2B9D9BBE@nortelnetworks.com…
#include <stdlib.h
#include <stdio.h
#include <sys/stat.hint main () {
struct stat buf;if ( stat( “/proc”, &buf ) == -1) {
perror (“stat” );
return EXIT_FAILURE;
} else {
printf (“Free memory: %d Kbytes\n”, buf.st_size/1000);
return EXIT_SUCCESS;
}
}crib wrote:
hello
how can i know my memory space wich is available,
in C code.like with the utilitie " sin " with option " info "
thanks
Johannes <Jsukamtoh@infolink.co.id> wrote in message
news:bgo0sq$9u4$1@inn.qnx.com…
Does anyone know how to view the system virtual memory available and used?
Just like sin info in version 4.2
The same information doesn’t really apply in QNX6, since we’re running in a
flat non-segmented address space. Each process has its own 4G virtual
address range, but you can see the way it’s being used via ‘pidin mem’.
-Adam