Closed csgro closed 7 years ago
A related leak affects also the monitor, since the function pEventReader::readPendingDatagram creates the buffer dynamically and never delete it. For now the problem has been fixed by destroying manually the buffer after the use. I suggest leaving the task to the pDataBlock destructor.
We have a fix for this leak, now. In the new scheme each pDataBlock owns its underlying data buffer, and is responsible for releasing the memory when it goes out of scope. The relevant code is in the pDataBlock destructor:
+/*!Destructor. Delete the underlying data buffer.
+*/
+pDataBlock::~pDataBlock()
+{
+ if (m_rawBuffer) delete[] m_rawBuffer;
+}
+
+
A consequence of this change is that now, in the main loop of pDataCollector::run(), we need to instantiate a new buffer at each iteration, as opposed to overwrite always the same buffer instantiated at the beginning. The change has been propagated in the pEventReader::readDatagram() function of the monitor application.
We just committed this change
The underlying
m_rawBuffer
is created vianew
and the pDataBlock destructor is a do-nothing one, so this is effectively a memory leak. In the main data acquisition class the buffer is created statically, which is why we're not deleting it in the destructor. The right thing to do would probably be to usenew
in pDataCollector and implement a real destructor.