diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-11-22 21:35:27 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-11-22 21:35:27 +0000 |
| commit | 1959df2c9c2ee2a0b82d08fb6fe0bdfb32d70598 (patch) | |
| tree | 7018c720434c92a9c3b37084f00121f0e798d6a1 /lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp | |
| parent | 01575f86aa6dabbdd89f29696c80e3d9ffaa5de9 (diff) | |
| download | bcm5719-llvm-1959df2c9c2ee2a0b82d08fb6fe0bdfb32d70598.tar.gz bcm5719-llvm-1959df2c9c2ee2a0b82d08fb6fe0bdfb32d70598.zip | |
Shrink-to-fit our std::vector<DWARFDebugInfoEntry> collections and save 20%
to 30% of memory. The size doubling was killing us and we ended up with up to
just under 50% of empty capacity. Cleaning this up saves us a ton of memory.
llvm-svn: 145086
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp')
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index aa8699f0ad2..096710cd258 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -271,7 +271,17 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only) } fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); } + + // Since std::vector objects will double their size, we really need to + // make a new array with the perfect size so we don't end up wasting + // space. So here we copy and swap to make sure we don't have any extra + // memory taken up. + if (m_die_array.size () < m_die_array.capacity()) + { + DWARFDebugInfoEntry::collection exact_size_die_array (m_die_array.begin(), m_die_array.end()); + exact_size_die_array.swap (m_die_array); + } LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO)); if (log) { |

