Skip to content

Commit 2949e3e

Browse files
committed
fix memory leak in trainBinarySVM
1 parent bdb4348 commit 2949e3e

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

mascot/svmMain.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ int main(int argc, char **argv)
5454

5555
}
5656

57-
return 0;
57+
return 0;
5858
}

mascot/svmModel.cu

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
//
2-
// Created by ss on 16-11-2.
3-
//
1+
/*
2+
* @author: created by ss on 16-11-2.
3+
* @brief: multi-class svm training, prediction, svm with probability output
4+
*
5+
*/
46

57
#include <cstdio>
68
#include "svmModel.h"

mascot/trainingFunction.cu

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
using std::cout;
3333
using std::endl;
3434

35-
void trainingByGPU(vector<vector<float_point> > &v_v_DocVector, data_info &SDataInfo, SVMParam &param);
36-
3735
svmModel trainSVM(SVMParam &param, string strTrainingFileName, int nNumofFeature) {
3836

3937
vector<vector<float_point> > v_v_DocVector;
@@ -169,6 +167,20 @@ svm_model trainBinarySVM(svmProblem &problem, const SVMParam &param) {
169167
}
170168

171169
model.nDimension = problem.getNumOfFeatures();
170+
171+
//free device memory
172+
checkCudaErrors(cudaFree(pfDevAlphaSubset));
173+
checkCudaErrors(cudaFree(pnDevLabelSubset));
174+
checkCudaErrors(cudaFree(pfDevYiGValueSubset));
175+
176+
//release pinned memory
177+
cudaFreeHost(DeviceHessian::m_pfHessianRowsInHostMem);
178+
179+
//release host memory
180+
delete[] DeviceHessian::m_pfHessianDiag;
181+
delete[] pfAlphaAll;
182+
delete[] pfYiGValueAll;
183+
172184
return model;
173185
}
174186

0 commit comments

Comments
 (0)