1
0
forked from 0ad/0ad
0ad/source
wraitii 2cc071f306 Fix memory leak introduced by 3a839517ce in SparseGrid
Following 3a839517ce, SparseGrid::Reset() replaces the value of m_Data
(a C-style dynamically sized array) with a new value-initialised array,
by using the new operator. Previous code simply did a memset.
This means that when m_Data was not null, it leaked memory as the
previous array was not deleted.

SparseGrid::Reset is called when destroying the sparse grid, and a
SparseGrid is used by the long pathfinder when computing JPS paths. As
that is called rather often, it resulted in a relatively serious memory
leak that could make very long games use several GB of memory.

This fixes the leak by using placement new, which re-uses the memory,
effectively doing the same as the previously existing memset.

Profiling by historic_bruno and elexis showed that performance from
value-initialising with placement new was at worst similar to memset,
and testing shows this was compiled in a memset call in several cases
anyways.

Reviewed By: elexis
Fixes #5522

Differential Revision: https://code.wildfiregames.com/D2121
This was SVN commit r22545.
2019-07-24 17:11:22 +00:00
..
collada Fix compiler warnings on VS 2015, refs #3439, refs #5069. 2018-03-10 09:58:53 +00:00
graphics Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later. 2019-07-22 19:35:14 +00:00
gui Use FromJSVal ToJSVal for primitive types to remove the duplicate logic and make JSInterface_IGUIObject case handling more equal. 2019-07-24 02:58:50 +00:00
i18n Simple refactoring of Singleton. Make it non-copyable. 2019-01-13 15:11:40 +00:00
lib Revert 09916ce6cb which broken jenkins build. 2019-07-20 13:10:53 +00:00
lobby Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later. 2019-07-22 19:35:14 +00:00
maths Cleanups BoundingBoxAxisAligned and fixes coding styles a bit. 2019-06-12 20:23:14 +00:00
mocks More FreeBSD build fixes. 2012-01-30 06:21:11 +00:00
network Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later. 2019-07-22 19:35:14 +00:00
pch Update precompiled headers to improve build times. 2019-05-26 07:21:12 +00:00
ps Alt+tab fix for ca9109be75 - call sound IdleTask in Atlas and swap buffers only once in Atlas. 2019-07-24 16:40:34 +00:00
renderer Refactors camera projections - makes projection functions of camera more clear. 2019-06-26 22:54:05 +00:00
scriptinterface Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later. 2019-07-22 19:35:14 +00:00
simulation2 Fix memory leak introduced by 3a839517ce in SparseGrid 2019-07-24 17:11:22 +00:00
soundmanager Fix lineendings. 2019-07-12 17:40:40 +00:00
third_party Removes deprecated 'register' storage class from mongoose. Refs #3068 2019-07-18 06:28:51 +00:00
tools Alt+tab fix for ca9109be75 - call sound IdleTask in Atlas and swap buffers only once in Atlas. 2019-07-24 16:40:34 +00:00
main.cpp Alt+tab fix for ca9109be75 - call sound IdleTask in Atlas and swap buffers only once in Atlas. 2019-07-24 16:40:34 +00:00
test_setup.cpp Fix string format of the JS test assertion failure following 7c2e9027c2 (cxxtest expects a char* instead of a std::wstring, so newlines were printed as \n characters). 2017-10-13 21:56:45 +00:00