Esempio n. 1
0
IMPORT_EXPORT_MALLOC_DLL unsigned long GetLargestFreeMemoryRegion(void)
{
#ifdef USE_DYNAMIC_STACK
    /* we need to limit values to 32 bits for Scilab :( */
    return MAXLONG32;
#else
    struct rlimit rlim;
    unsigned long largestSize, freeMem;

    /* HP-UX Use RLIMIT_AIO_MEM instead of RLIMIT_MEMLOCK */
    /* FIXME -- this should be an autoconf test to see which RLIMIT_foo is defined */
    #ifdef solaris
    getrlimit(RLIMIT_VMEM,&rlim);
    #elif defined(__NetBSD__) || defined(__DragonFly__)
    getrlimit(RLIMIT_RSS,&rlim);
    #else	
    getrlimit(RLIMIT_AS, &rlim);
    #endif
    if(rlim.rlim_max == RLIM_INFINITY)
    {
        largestSize = LONG_MAX;
    }
    else
    {
        largestSize = rlim.rlim_max;
    }

    freeMem = getfreememory()*1024;
    if(freeMem < largestSize)
    {
        return freeMem;
    }
    else
    {
        return largestSize;
    }

    return largestSize;
#endif /* #ifdef USE_DYNAMIC_STACK */
}
Esempio n. 2
0
types::Function::ReturnValue sci_getmemory(types::typed_list &in, int _iRetCount, types::typed_list &out)
{
    if (in.size() > 0)
    {
        Scierror(77, _("%s: Wrong number of input argument(s): %d expected."), "funcprot", 0);
        return types::Function::Error;
    }

    if (_iRetCount > 2)
    {
        Scierror(77, _("%s: Wrong number of output argument(s): %d expected."), "funcprot", 2);
        return types::Function::Error;
    }

    out.push_back(new types::Double((double)getfreememory()));

    if(_iRetCount == 2)
    {
        out.push_back(new types::Double((double)getmemorysize()));
    }

    return types::Function::OK;
}