EnglishУкраїнськаmRussian
Login/New
Topic with no new replies

[BugWrong] Memory Leakage in TValBuf


Author Message
Written on: 07. 03. 2017 [10:00]
amirkhan63
amir amir
Topic creator
registered since: 07.03.2017
Posts: 2
Hi,
I was tested my project developed on openscada 0.8.17 with Valgrind and massif and reported memory leakage on tarchval.cpp (function: void TValBuf::TBuf<TpVal>::set( TpVal value, int64_t tm )) code below:
JAVASCRIPT
//>>> Memory consumption is made optimal for limited size
		    if((int)buf.grid->capacity() > size)
		    {
			vector<TpVal> *ns = new vector<TpVal>;
			*ns = *buf.grid;
			delete buf.grid;
			buf.grid = ns;
		    }

line '*ns = *buf.grid;' reported as memory leak and I wondering this part of code means what. Can you explain this part of code?
thank you
Written on: 07. 03. 2017 [10:09]
roman
Roman Savochenko
Moderator
Contributor
Developer
registered since: 12.12.2007
Posts: 3742
"amirkhan63" wrote:

line '*ns = *buf.grid;' reported as memory leak and I wondering this part of code means what. Can you explain this part of code?
thank you

There is no memory leakage and the code designed to drop spare (reserved by vector on push in twice size of the array on the push time) items into buf.grid by its recreation and copy the presented-real items:
Memory consumption is made optimal for limited size


The same line '*ns = *buf.grid;' only performs the items copy by the standard copy function of the STL Vector, which isn't OpenSCADA code at all!

And sure I have not any real leakages on my projects here!

P.S. If you about a reporter mean "valgrind" then it's wrong often for the STL containers.

Learn, learn and learn better than work, work and work.



12580