Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - check for largest free contiguous memory block: (3 Items)
   
check for largest free contiguous memory block  
I wonder if there is a lightweight method to check for the largest available contiguous memory block. 
I would like to know this value before an application fails with mmap("MAP_PHYS | MAP_ANON") call.

Currently I check it with a tool that tries to allocate contiguous memory blocks with descending size starting with 
maximum free memory size until call succeeds. But this has the great constraint that in a running system another process
 that requests contiguous memory at the same time may fail. 
The better way would be a call (at kernel or memmgr side) that needn't allocate memory at all. 
RE: check for largest free contiguous memory block  
  fd = posix_typed_mem_open("sysram", O_RDONLY, POSIX_TYPED_MEM_ALLOC_CONTIG);
  posix_typed_mem_get_info(fd, &info);
  close(fd);

  // contig free size in info.posix_tmi_length

Of course, just because that amount is free at the point of the posix_type_mem_get_info() doesn't mean that a mmap() for
 that amount will succeed - something else could allocate memory between the two calls.
________________________________________
From: Thomas Schickentanz [community-noreply@qnx.com]
Sent: March-31-15 3:33 AM
To: ostech-core_os
Subject: check for largest free contiguous memory block

I wonder if there is a lightweight method to check for the largest available contiguous memory block.
I would like to know this value before an application fails with mmap("MAP_PHYS | MAP_ANON") call.

Currently I check it with a tool that tries to allocate contiguous memory blocks with descending size starting with 
maximum free memory size until call succeeds. But this has the great constraint that in a running system another process
 that requests contiguous memory at the same time may fail.
The better way would be a call (at kernel or memmgr side) that needn't allocate memory at all.



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post113646
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com
Re: check for largest free contiguous memory block  
Thanks very much!
That is exactly what I am looking for.