From 6124e8e4400cc42cfaf986f8c265824aebb9a80d Mon Sep 17 00:00:00 2001 From: Aaron Cuevas Lopez <aacuelo@teleco.upv.es> Date: Fri, 3 Nov 2017 03:24:52 +0100 Subject: [PATCH] Fix some memory leaks --- Source/Plugins/SpikeSorter/SpikeSortBoxes.cpp | 2 +- Source/Plugins/SpikeSorter/SpikeSorter.cpp | 5 +---- Source/Plugins/SpikeSorter/SpikeSorter.h | 8 +++++--- Source/Plugins/SpikeSorter/SpikeSorterEditor.cpp | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/Plugins/SpikeSorter/SpikeSortBoxes.cpp b/Source/Plugins/SpikeSorter/SpikeSortBoxes.cpp index a6e38a8c0..7a8f482a6 100644 --- a/Source/Plugins/SpikeSorter/SpikeSortBoxes.cpp +++ b/Source/Plugins/SpikeSorter/SpikeSortBoxes.cpp @@ -2129,7 +2129,7 @@ void PCAjob::computeSVD() // delete covariances for (int k = 0; k < dim; k++) - delete cov[k]; + delete[] cov[k]; delete[] cov; cov = nullptr; diff --git a/Source/Plugins/SpikeSorter/SpikeSorter.cpp b/Source/Plugins/SpikeSorter/SpikeSorter.cpp index 3e770324f..fc182f087 100644 --- a/Source/Plugins/SpikeSorter/SpikeSorter.cpp +++ b/Source/Plugins/SpikeSorter/SpikeSorter.cpp @@ -219,9 +219,6 @@ Electrode::~Electrode() delete[] voltageScale; delete[] channels; delete[] runningStats; - - delete spikeSort; - } Electrode::Electrode(int ID, UniqueIDgenerator* uniqueIDgenerator_, PCAcomputingThread* pth, String _name, int _numChannels, int* _channels, float default_threshold, int pre, int post, float samplingRate , int sourceId, int subIdx) @@ -1125,7 +1122,7 @@ void SpikeSorter::addProbes(String probeType,int numProbes, int nElectrodesPerPr increaseUniqueProbeID(probeType); } } -Array<Electrode*> SpikeSorter::getElectrodes() +const OwnedArray<Electrode>& SpikeSorter::getElectrodes() { return electrodes; } diff --git a/Source/Plugins/SpikeSorter/SpikeSorter.h b/Source/Plugins/SpikeSorter/SpikeSorter.h index 8f93e89a2..7938615c5 100644 --- a/Source/Plugins/SpikeSorter/SpikeSorter.h +++ b/Source/Plugins/SpikeSorter/SpikeSorter.h @@ -173,9 +173,11 @@ public: RunningStat* runningStats; SpikeHistogramPlot* spikePlot; - SpikeSortBoxes* spikeSort; + PCAcomputingThread* computingThread; UniqueIDgenerator* uniqueIDgenerator; + + ScopedPointer<SpikeSortBoxes> spikeSort; bool isMonitored; }; @@ -361,7 +363,7 @@ public: void setElectrodeVoltageScale(int electrodeID, int index, float newvalue); std::vector<int> getElectrodeChannels(int ID); - Array<Electrode*> getElectrodes(); + const OwnedArray<Electrode>& getElectrodes(); std::vector<String> electrodeTypes; @@ -437,7 +439,7 @@ private: int& currentChannel); - Array<Electrode*> electrodes; + OwnedArray<Electrode> electrodes; PCAcomputingThread computingThread; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SpikeSorter); diff --git a/Source/Plugins/SpikeSorter/SpikeSorterEditor.cpp b/Source/Plugins/SpikeSorter/SpikeSorterEditor.cpp index d1c554dd5..5a6d36e5a 100644 --- a/Source/Plugins/SpikeSorter/SpikeSorterEditor.cpp +++ b/Source/Plugins/SpikeSorter/SpikeSorterEditor.cpp @@ -463,7 +463,7 @@ void SpikeSorterEditor::buttonEvent(Button* button) SpikeSorter* processor = (SpikeSorter*) getProcessor(); - Array<Electrode*> electrodes = processor->getElectrodes(); + const OwnedArray<Electrode>& electrodes = processor->getElectrodes(); for (int i = 0; i < electrodes.size(); i++) { -- GitLab