//----------------------------------------------------------------------------
-size_t
+bool
VISU_PipeLine
-::CheckAvailableMemory(size_t theSize)
+::CheckAvailableMemory(double theSize)
{
if(theSize < ULONG_MAX){
try{
- if(char *aCheck = new char[theSize]){
+ size_t aSize = size_t(theSize);
+ if(char *aCheck = new char[aSize]){
delete [] aCheck;
- return theSize;
+ return true;
}
}catch(std::bad_alloc& exc){
}catch(...){
}
}
- return 0;
+ return false;
}
size_t theMinSize)
{
// Finds acceptable memory size by half-deflection methods
- static size_t EPSILON = 2 * 1024;
- size_t aMax = std::max(theSize, theMinSize);
- size_t aMin = std::min(theSize, theMinSize);
+ static double EPSILON = 2 * 1024;
+ double aMax = std::max(theSize, theMinSize);
+ double aMin = std::min(theSize, theMinSize);
//cout<<"GetAvailableMemory - "<<aMax<<"; "<<aMin;
- while(CheckAvailableMemory(aMax) == 0 && CheckAvailableMemory(aMin) > 0 && (aMax - aMin) > EPSILON){
- size_t aRoot = (aMax + aMin) / 2;
+ while(!CheckAvailableMemory(aMax) && CheckAvailableMemory(aMin) && (aMax - aMin) > EPSILON){
+ double aRoot = (aMax + aMin) / 2.;
if(CheckAvailableMemory(aRoot))
aMin = aRoot;
else
aMax = aRoot;
}
//cout<<"; "<<aMax<<endl;
- return aMax;
+ return (size_t)aMax;
}
//----------------------------------------------------------------------------
static
- size_t
- CheckAvailableMemory(size_t theSize);
-
+ bool
+ CheckAvailableMemory(double theSize);
+
static
size_t
GetAvailableMemory(size_t theSize,