Filesystem vs malloc space

Joel Sherrill <joel@OARcorp.com> joel.sherrill at OARcorp.com
Tue Apr 26 18:42:27 UTC 2005


Thomas Doerfler wrote:
> Angelo Fraietta schrieb:
> 
> I think you missinterprete the functionality of
> IMFS_memfile_maximum_size(): It does not return the amount of memory
> left for file creation, but returns a constant, that defines the maximum
> file size, that can be created using the IMFS, even if more memory would
> be available. In normal configurations, the size of each file is limited
> to 4MByte.

That's the answer. :)

The function exists because you can (at compile time) configure the 
block size used by the IMFS.  If you pick a small block size, you
get a smaller maximum file size.  From cpukit/libfs/src/imfs/imfs.h

/*
  *  IMFS "memfile" information
  *
  *  The data structure for the in-memory "memfiles" is based on classic 
UNIX.
  *
  *  block_ptr is a pointer to a block of IMFS_MEMFILE_BYTES_PER_BLOCK in
  *  length which could be data or a table of pointers to blocks.
  *
  *  Setting IMFS_MEMFILE_BYTES_PER_BLOCK to different values has a 
significant
  *  impact on the maximum file size supported as well as the amount of
  *  memory wasted due to internal file fragmentation.  The following
  *  is a list of maximum file sizes based on various settings
  *
  *    max_filesize with blocks of   16 is         1,328
  *    max_filesize with blocks of   32 is        18,656
  *    max_filesize with blocks of   64 is       279,488
  *    max_filesize with blocks of  128 is     4,329,344
  *    max_filesize with blocks of  256 is    68,173,568
  *    max_filesize with blocks of  512 is 1,082,195,456
  */



> wkr,
> Thomas.
> 
> 
>>Greetings all
>>
>>I have found that I am running out of malloc memory on my system
>>By doing the following two calls, I can see how much memory I have
>>
>>           printf ("\r\nFree Space %u", malloc_free_space());
>>           printf("\r\nMax Filesystem Size %u",
>>IMFS_memfile_maximum_size());
>>
>>At first, I have approx 5527408 bytes of malloc memory and 4329344 bytes
>>of free filesystem space.
>>
>>After loading a heap of data, I end up with approx 207000 bytes of
>>malloc memory left, buts still have the same amount of Filesystem space
>>left (this is strange as I have just downloaded nearly 100K of files to
>>my system). This 200K of malloc space that I have left is still not
>>enough to dod what I still have to do
>>
>>How do I reduce the amount of filesystem space and increase the amount
>>of space for malloc?
>>Why didn't the Filesystem space show the difference; or is it that the
>>call I made shows the total IMFS space- not the amount remaining.
>>
>>Thanks
>>
> 
> 
> 


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985




More information about the users mailing list