[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Fri Dec 9 14:49:40 UTC 2011
SVN commit 1267876 by netterfield:
BUG:
the free-memory checker was failing under 32 bit linux. Use double instead so it always works.
M +3 -3 libkst/datacollection.cpp
M +1 -1 libkst/datacollection.h
M +5 -5 libkstapp/changedatasampledialog.cpp
M +7 -7 libkstapp/datawizard.cpp
--- branches/work/kst/portto4/kst/src/libkst/datacollection.cpp #1267875:1267876
@@ -37,8 +37,8 @@
return ::malloc(size);
}
-unsigned long Data::AvailableMemory() {
- unsigned long available_memory = 1024*1024*1024;
+double Data::AvailableMemory() {
+ double available_memory = 1024.0*1024.0*1024.0;
// FIXME: under windows or mac, this is totally wrong.
// Under windows, try GlobalMemoryStatusEx
// (http://msdn.microsoft.com/en-us/library/aa366589)
@@ -47,7 +47,7 @@
#ifdef __linux__
QMutexLocker ml(&bigLock);
meminfo();
- available_memory = S(kb_main_free + kb_main_cached) - 30*1024*1024; // 30MB margin
+ available_memory = double(S(kb_main_free + kb_main_cached)) - 30.0*1024.0*1024.0; // 30MB margin
#endif
return available_memory;
}
--- branches/work/kst/portto4/kst/src/libkst/datacollection.h #1267875:1267876
@@ -58,7 +58,7 @@
*/
virtual int columns() const;
- static unsigned long AvailableMemory();
+ static double AvailableMemory();
};
/** Bad choice for location - maybe move it later */
--- branches/work/kst/portto4/kst/src/libkstapp/changedatasampledialog.cpp #1267875:1267876
@@ -245,11 +245,11 @@
// see if we have enough memory
//FIXME: doesn't consider data objects that depend on this, and it should
//FIXME: doesn't work under windows or mac
- long current_memory_used = 0;
- long memory_needed = 0;
+ double current_memory_used = 0.0;
+ double memory_needed = 0.0;
for (int i = 0; i < selectedItems.size(); ++i) {
if (DataVectorPtr vector = kst_cast<DataVector>(_store->retrieveObject(selectedItems.at(i)->text()))) {
- current_memory_used += vector->length()*sizeof(double);
+ current_memory_used += double(vector->length())*sizeof(double);
long ns=0;
if (_dataRange->readToEnd()) {
ns = vector->fileLength() - (int)_dataRange->start();
@@ -261,11 +261,11 @@
} else {
ns *= vector->samplesPerFrame();
}
- memory_needed += ns*sizeof(double);
+ memory_needed += double(ns)*sizeof(double);
}
}
- long memory_available = Data::AvailableMemory();
+ double memory_available = Data::AvailableMemory();
if (memory_needed-current_memory_used > memory_available) {
//QApplication::restoreOverrideCursor();
QMessageBox::warning(this, i18n("Insufficient Memory"), i18n("You requested to read in %1 MB of data but it seems that you only have approximately %2 MB of usable memory available. You cannot load this much data."
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1267875:1267876
@@ -776,8 +776,8 @@
emit dataSourceLoaded(ds->fileName());
// check for sufficient memory
- unsigned long memoryRequested = 0;
- unsigned long memoryAvailable = Data::AvailableMemory();
+ double memoryRequested = 0;
+ double memoryAvailable = Data::AvailableMemory();
double frames;
ds->writeLock();
@@ -793,9 +793,9 @@
}
if (_pageDataPresentation->dataRange()->doSkip() && _pageDataPresentation->dataRange()->skip() > 0) {
- memoryRequested += frames / _pageDataPresentation->dataRange()->skip() * sizeof(double);
+ memoryRequested += double(frames) / _pageDataPresentation->dataRange()->skip() * sizeof(double);
} else {
- memoryRequested += frames * ds->vector().dataInfo(_pageDataPresentation->vectorField()).samplesPerFrame * sizeof(double);
+ memoryRequested += double(frames) * ds->vector().dataInfo(_pageDataPresentation->vectorField()).samplesPerFrame * sizeof(double);
}
}
@@ -816,12 +816,12 @@
}
if (_pageDataPresentation->dataRange()->doSkip() && _pageDataPresentation->dataRange()->skip() > 0) {
- memoryRequested += frames / _pageDataPresentation->dataRange()->skip()*sizeof(double);
+ memoryRequested += double(frames) / _pageDataPresentation->dataRange()->skip()*sizeof(double);
} else {
- memoryRequested += frames * ds->vector().dataInfo(field).samplesPerFrame * sizeof(double);
+ memoryRequested += double(frames) * ds->vector().dataInfo(field).samplesPerFrame * sizeof(double);
}
if (_pageDataPresentation->plotPSD()) {
- memoryRequested += fftLen * 6;
+ memoryRequested += fftLen * 6.0;
}
}
}
More information about the Kst
mailing list