plug some memory leaks in libardour

This commit is contained in:
Robin Gareus 2016-04-24 14:41:07 +02:00
parent c4c6c38dbd
commit e3607a4c8b
8 changed files with 42 additions and 26 deletions

View file

@ -114,6 +114,7 @@ AudioEngine::~AudioEngine ()
for (BackendMap::const_iterator i = _backends.begin(); i != _backends.end(); ++i) { for (BackendMap::const_iterator i = _backends.begin(); i != _backends.end(); ++i) {
i->second->deinstantiate(); i->second->deinstantiate();
} }
delete _main_thread;
} }
AudioEngine* AudioEngine*
@ -1234,6 +1235,7 @@ AudioEngine::thread_init_callback (void* arg)
AsyncMIDIPort::set_process_thread (pthread_self()); AsyncMIDIPort::set_process_thread (pthread_self());
if (arg) { if (arg) {
delete AudioEngine::instance()->_main_thread;
/* the special thread created/managed by the backend */ /* the special thread created/managed by the backend */
AudioEngine::instance()->_main_thread = new ProcessThread; AudioEngine::instance()->_main_thread = new ProcessThread;
} }

View file

@ -85,13 +85,17 @@ Auditioner::init ()
Auditioner::~Auditioner () Auditioner::~Auditioner ()
{ {
if (asynth) {
asynth->drop_references ();
}
asynth.reset ();
} }
void void
Auditioner::lookup_synth () Auditioner::lookup_synth ()
{ {
string plugin_id = Config->get_midi_audition_synth_uri(); string plugin_id = Config->get_midi_audition_synth_uri();
asynth = boost::shared_ptr<Processor>(); asynth.reset ();
if (!plugin_id.empty()) { if (!plugin_id.empty()) {
boost::shared_ptr<Plugin> p; boost::shared_ptr<Plugin> p;
p = find_plugin (_session, plugin_id, ARDOUR::LV2); p = find_plugin (_session, plugin_id, ARDOUR::LV2);

View file

@ -412,15 +412,16 @@ Graph::helper_thread()
ProcessThread* pt = new ProcessThread (); ProcessThread* pt = new ProcessThread ();
resume_rt_malloc_checks (); resume_rt_malloc_checks ();
pt->get_buffers(); pt->get_buffers();
while(1) { while(1) {
if (run_one()) { if (run_one()) {
break; break;
} }
} }
pt->drop_buffers(); pt->drop_buffers();
delete pt;
} }
/** Here's the main graph thread */ /** Here's the main graph thread */
@ -431,35 +432,35 @@ Graph::main_thread()
ProcessThread* pt = new ProcessThread (); ProcessThread* pt = new ProcessThread ();
resume_rt_malloc_checks (); resume_rt_malloc_checks ();
pt->get_buffers(); pt->get_buffers();
again: again:
_callback_start_sem.wait (); _callback_start_sem.wait ();
DEBUG_TRACE(DEBUG::ProcessThreads, "main thread is awake\n"); DEBUG_TRACE(DEBUG::ProcessThreads, "main thread is awake\n");
if (!_threads_active) { if (!_threads_active) {
return; return;
} }
prep (); prep ();
if (_graph_empty && _threads_active) { if (_graph_empty && _threads_active) {
_callback_done_sem.signal (); _callback_done_sem.signal ();
DEBUG_TRACE(DEBUG::ProcessThreads, "main thread sees graph done, goes back to sleep\n"); DEBUG_TRACE(DEBUG::ProcessThreads, "main thread sees graph done, goes back to sleep\n");
goto again; goto again;
} }
/* This loop will run forever */ /* This loop will run forever */
while (1) { while (1) {
DEBUG_TRACE(DEBUG::ProcessThreads, "main thread runs one graph node\n"); DEBUG_TRACE(DEBUG::ProcessThreads, "main thread runs one graph node\n");
if (run_one()) { if (run_one()) {
break; break;
} }
} }
pt->drop_buffers(); pt->drop_buffers();
delete (pt); delete (pt);
} }
void void

View file

@ -808,6 +808,7 @@ LV2Plugin::~LV2Plugin ()
#endif #endif
free(_features); free(_features);
free(_log_feature.data);
free(_make_path_feature.data); free(_make_path_feature.data);
free(_work_schedule_feature.data); free(_work_schedule_feature.data);
@ -828,6 +829,7 @@ LV2Plugin::~LV2Plugin ()
delete [] _shadow_data; delete [] _shadow_data;
delete [] _defaults; delete [] _defaults;
delete [] _ev_buffers; delete [] _ev_buffers;
delete _impl;
} }
bool bool

View file

@ -126,6 +126,8 @@ Processor::state (bool full_state)
XMLNode& automation = Automatable::get_automation_xml_state(); XMLNode& automation = Automatable::get_automation_xml_state();
if (!automation.children().empty() || !automation.properties().empty()) { if (!automation.children().empty() || !automation.properties().empty()) {
node->add_child_nocopy (automation); node->add_child_nocopy (automation);
} else {
delete &automation;
} }
} }

View file

@ -101,6 +101,7 @@
#include "ardour/source_factory.h" #include "ardour/source_factory.h"
#include "ardour/speakers.h" #include "ardour/speakers.h"
#include "ardour/tempo.h" #include "ardour/tempo.h"
#include "ardour/ticker.h"
#include "ardour/track.h" #include "ardour/track.h"
#include "ardour/user_bundle.h" #include "ardour/user_bundle.h"
#include "ardour/utils.h" #include "ardour/utils.h"
@ -306,6 +307,7 @@ Session::Session (AudioEngine &eng,
, _speakers (new Speakers) , _speakers (new Speakers)
, _order_hint (-1) , _order_hint (-1)
, ignore_route_processor_changes (false) , ignore_route_processor_changes (false)
, midi_clock (0)
, _scene_changer (0) , _scene_changer (0)
, _midi_ports (0) , _midi_ports (0)
, _mmc (0) , _mmc (0)
@ -739,6 +741,7 @@ Session::destroy ()
delete _midi_ports; _midi_ports = 0; delete _midi_ports; _midi_ports = 0;
delete _locations; _locations = 0; delete _locations; _locations = 0;
delete midi_clock;
delete _tempo_map; delete _tempo_map;
DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n"); DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n");

View file

@ -251,6 +251,7 @@ Session::post_engine_init ()
/* MidiClock requires a tempo map */ /* MidiClock requires a tempo map */
delete midi_clock;
midi_clock = new MidiClockTicker (); midi_clock = new MidiClockTicker ();
midi_clock->set_session (this); midi_clock->set_session (this);

View file

@ -395,6 +395,7 @@ int main (int argc, char **argv)
event_loop->run(); event_loop->run();
free (line); free (line);
} }
free (line);
printf ("\n"); printf ("\n");
if (_session) { if (_session) {