Skip to content

Commit

Permalink
bug fix for memory leak for every multi threading command when using API
Browse files Browse the repository at this point in the history
  • Loading branch information
thattil committed Jun 12, 2018
1 parent 17c2074 commit 7462d10
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
5 changes: 4 additions & 1 deletion slsDetectorSoftware/slsDetector/slsDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ slsDetector::~slsDetector(){
else
printf("Shared memory %d detached\n", shmId);
#endif
delete thisReceiver;
if(controlSocket) delete controlSocket;
if(stopSocket) delete stopSocket;
if(dataSocket) delete dataSocket;
if(thisReceiver) delete thisReceiver;
};

slsDetector::slsDetector(int pos, char *name, int id, int cport,multiSlsDetector *p) : slsDetectorUtils(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ receiverInterface::receiverInterface(MySocketTCP *socket):dataSocket(socket){}



receiverInterface::~receiverInterface(){
delete dataSocket;
}
receiverInterface::~receiverInterface(){}



Expand Down
29 changes: 27 additions & 2 deletions slsDetectorSoftware/threadFiles/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class SuperTask: public virtual slsDetectorDefs {
public:
SuperTask():
m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0){};
~SuperTask(){};
virtual ~SuperTask(){};
protected:
/** Function signature defined
* First argument is Return type, the remaining are arguments
Expand Down Expand Up @@ -159,7 +159,32 @@ class Task: public virtual SuperTask {
Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(17){m17 = t;};
Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(18){m18 = t;};

~Task(){}
virtual ~Task(){
switch(fnum) {
case 1: delete m1; break;
case 2: delete m2; break;
case 3: delete m3; break;
case 4: delete m4; break;
case 5: delete m5; break;
case 6: delete m6; break;
case 7: delete m7; break;
case 8: delete m8; break;
case 9: delete m9; break;
case 10: delete m10; break;
case 11: delete m11; break;
case 12: delete m12; break;
case 13: delete m13; break;
case 14: delete m14; break;
case 15: delete m15; break;
case 16: delete m16; break;
case 17: delete m17; break;
case 18: delete m18; break;
default:
cprintf(RED, "Error: Task not defined. Abort!\n");
break;
}

};

void operator()(){
switch(fnum) {
Expand Down

0 comments on commit 7462d10

Please sign in to comment.