Skip to content

Commit

Permalink
fix memory leak in trainBinarySVM
Browse files Browse the repository at this point in the history
  • Loading branch information
zeyiwen committed Nov 8, 2016
1 parent bdb4348 commit 2949e3e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mascot/svmMain.cu
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ int main(int argc, char **argv)

}

return 0;
return 0;
}
8 changes: 5 additions & 3 deletions mascot/svmModel.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//
// Created by ss on 16-11-2.
//
/*
* @author: created by ss on 16-11-2.
* @brief: multi-class svm training, prediction, svm with probability output
*
*/

#include <cstdio>
#include "svmModel.h"
Expand Down
16 changes: 14 additions & 2 deletions mascot/trainingFunction.cu
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
using std::cout;
using std::endl;

void trainingByGPU(vector<vector<float_point> > &v_v_DocVector, data_info &SDataInfo, SVMParam &param);

svmModel trainSVM(SVMParam &param, string strTrainingFileName, int nNumofFeature) {

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

model.nDimension = problem.getNumOfFeatures();

//free device memory
checkCudaErrors(cudaFree(pfDevAlphaSubset));
checkCudaErrors(cudaFree(pnDevLabelSubset));
checkCudaErrors(cudaFree(pfDevYiGValueSubset));

//release pinned memory
cudaFreeHost(DeviceHessian::m_pfHessianRowsInHostMem);

//release host memory
delete[] DeviceHessian::m_pfHessianDiag;
delete[] pfAlphaAll;
delete[] pfYiGValueAll;

return model;
}

Expand Down

0 comments on commit 2949e3e

Please sign in to comment.