Fix up free space calculation.

This commit is contained in:
W. Eric Norum
2008-05-11 21:28:55 +00:00
parent 12a5014193
commit e40ef4996a
2 changed files with 13 additions and 13 deletions

View File

@@ -323,17 +323,15 @@ static void netStatCallFunc(const iocshArgBuf *args)
static const iocshFuncDef heapSpaceFuncDef = {"heapSpace",0,NULL};
static void heapSpaceCallFunc(const iocshArgBuf *args)
{
rtems_malloc_statistics_t stats;
rtems_malloc_statistics_t s;
double x;
malloc_get_statistics(&stats);
if (stats.space_available >= 1024*1024) {
double x = (double)stats.space_available / (1024 * 1024);
printf("Heap space: %.1f MB\n", x);
}
else {
double x = (double)stats.space_available / 1024;
printf("Heap space: %.1f kB\n", x);
}
malloc_get_statistics(&s);
x = s.space_available - (unsigned long)(s.lifetime_allocated - s.lifetime_freed);
if (x >= 1024*1024)
printf("Heap space: %.1f MB\n", x / (1024 * 1024));
else
printf("Heap space: %.1f kB\n", x / 1024);
}
#ifndef OMIT_NFS_SUPPORT

View File

@@ -17,8 +17,10 @@
*/
epicsShareFunc int epicsShareAPI osiSufficentSpaceInPool ( size_t contiguousBlockSize )
{
rtems_malloc_statistics_t stats;
rtems_malloc_statistics_t s;
unsigned long n;
malloc_get_statistics(&stats);
return (stats.space_available > (50000 + contiguousBlockSize));
malloc_get_statistics(&s);
n = s.space_available - (unsigned long)(s.lifetime_allocated - s.lifetime_freed);
return (n > (50000 + contiguousBlockSize));
}