static uint32_t
GetNumberAllocatedModules();
+ %feature("docstring", "
+ Removes all modules which are no longer needed by any part of LLDB from
+ the module cache.
+
+ This is an implementation detail exposed for testing and should not be
+ relied upon. Use SBDebugger::MemoryPressureDetected instead to reduce
+ LLDB's memory consumption during execution.
+ ") GarbageCollectAllocatedModules;
+ static void
+ GarbageCollectAllocatedModules();
+
STRING_EXTENSION(SBModule)
#ifdef SWIGPYTHON
/// Get the number of global modules.
static uint32_t GetNumberAllocatedModules();
+ /// Remove any global modules which are no longer needed.
+ static void GarbageCollectAllocatedModules();
+
private:
friend class SBAddress;
friend class SBFrame;
lldb.SBDebugger.Destroy(self.dbg)
del self.dbg
+ # All modules should be orphaned now so that they can be cleared from
+ # the shared module cache.
+ lldb.SBModule.GarbageCollectAllocatedModules()
+
+ # Modules are not orphaned during reproducer replay because they're
+ # leaked on purpose.
+ if not configuration.is_reproducer():
+ # Assert that the global module cache is empty.
+ self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
+
+
# =========================================================
# Various callbacks to allow introspection of test progress
# =========================================================
for target in targets:
self.dbg.DeleteTarget(target)
- # Modules are not orphaned during reproducer replay because they're
- # leaked on purpose.
if not configuration.is_reproducer():
# Assert that all targets are deleted.
- assert self.dbg.GetNumTargets() == 0
- # Assert that the global module cache is empty.
- assert lldb.SBModule.GetNumberAllocatedModules() == 0
+ self.assertEqual(self.dbg.GetNumTargets(), 0)
# Do this last, to make sure it's in reverse order from how we setup.
Base.tearDown(self)
return Module::GetNumberAllocatedModules();
}
+void SBModule::GarbageCollectAllocatedModules() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBModule,
+ GarbageCollectAllocatedModules);
+ const bool mandatory = false;
+ ModuleList::RemoveOrphanSharedModules(mandatory);
+}
+
namespace lldb_private {
namespace repro {