Bug: Surface Grid of HybridSigmaPressureGrid is sometimes deleted by not memory managed object.
Explanation: When using multi threading, sometimes some grids are requested multiple times and therefore, also computed multiple times. The one on the slower thread finishes last, hence, the data is already present in the memory manager and the duplicate can be deleted. However, on deletion, the surface grid of it will be deleted (not released), since no memory manager has been set for it. Still, its surface grid might be already memory managed, and therefore, should be released, not deleted. Fix: Add/change the following lines:
MLonLatHybridSigmaPressureGrid::~MLonLatHybridSigmaPressureGrid() { // If the surface pressure field was set by the friend class // MWeatherPredictionReader, the field was stored in the same memory // manager as this item. If this item is deleted from the memory manager, // release the surface pressure field. // If this grid is not registered with any memory manager simply delete // the surface pressure grid. if (surfacePressure) {
if (**surfacePressure->getMemoryManager()**)
{
LOG4CPLUS_TRACE(mlog, "Releasing psfc of request "
<< getGeneratingRequest().toStdString());
**surfacePressure->getMemoryManager()**->releaseData(surfacePressure);
}
else
{
abstractDataItem.h: public: MAbstractMemoryManager getMemoryManager(){return memoryManager;}*