On 05/24/2014 02:47 PM, William Bonnet wrote:
Even if it may look like a memory leak, it is not really one since the
memory will be released after the document is closed. The problem exist
on recent versions of LO, including master.
("Space leak" is jargon for such symptoms, cf.
<http://queue.acm.org/detail.cfm?id=2538488> "Leaking Space.")
--- multi_type_vector_types.hpp.orig 2014-05-24 13:53:09.482797120 +0200
+++ multi_type_vector_types.hpp 2014-05-24 13:55:39.049154637 +0200
@@ -249,6 +249,12 @@
static void resize_block(base_element_block& blk, size_t new_size)
{
static_cast<_Self&>(blk).m_array.resize(new_size);
+ // Test if the vector have allocated capacity (thus memory) superior to
+ // twice its current size. If yes thus, shrink its memory footprint
+ // Vector from STL does not free its memory when its downsized
+ if (static_cast<_Self&>(blk).m_array.capacity() > (2 * new_size)) {
This should probably use "/2" instead of "*2" to avoid overflow.
+ static_cast<_Self&>(blk).m_array.shrink_to_fit();
Two problems with std::vector's shrink_to_fit are that it is a C++11
addition and that it is merely a non-binding request to reduce capacity.
Stephan
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.