[Lldb-commits] [lldb] r145069 - in /lldb/trunk: include/lldb/Symbol/Symtab.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Greg Clayton
gclayton at apple.com
Tue Nov 22 10:47:25 PST 2011
Author: gclayton
Date: Tue Nov 22 12:47:24 2011
New Revision: 145069
URL: http://llvm.org/viewvc/llvm-project?rev=145069&view=rev
Log:
12% allocated memory savings when debugging clang with DWARF in .o files by
making sure we perfectly size our vector of symbols on the symbol table.
Modified:
lldb/trunk/include/lldb/Symbol/Symtab.h
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Modified: lldb/trunk/include/lldb/Symbol/Symtab.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=145069&r1=145068&r2=145069&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symtab.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symtab.h Tue Nov 22 12:47:24 2011
@@ -78,6 +78,16 @@
static void DumpSymbolHeader (Stream *s);
+
+ void Finalize ()
+ {
+ // Shrink to fit the symbols so we don't waste memory
+ if (m_symbols.capacity() > m_symbols.size())
+ {
+ collection new_symbols (m_symbols.begin(), m_symbols.end());
+ m_symbols.swap (new_symbols);
+ }
+ }
protected:
typedef std::vector<Symbol> collection;
typedef collection::iterator iterator;
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=145069&r1=145068&r2=145069&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Nov 22 12:47:24 2011
@@ -320,6 +320,7 @@
m_symtab_ap.reset(new Symtab(this));
Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
ParseSymtab (true);
+ m_symtab_ap->Finalize ();
}
return m_symtab_ap.get();
}
@@ -1488,6 +1489,8 @@
}
}
}
+
+
return symtab->GetNumSymbols();
}
More information about the lldb-commits
mailing list