Merge lp:~verifydtapn-contributers/verifydtapn/WaitinglistMemoryleakFix into lp:verifydtapn

Proposed by Peter Gjøl Jensen
Status: Merged
Approved by: Jiri Srba
Approved revision: 275
Merged at revision: 273
Proposed branch: lp:~verifydtapn-contributers/verifydtapn/WaitinglistMemoryleakFix
Merge into: lp:verifydtapn
Diff against target: 96 lines (+12/-3)
3 files modified
src/DiscreteVerification/DataStructures/PWList.cpp (+1/-0)
src/DiscreteVerification/DataStructures/PWList.hpp (+5/-3)
src/DiscreteVerification/DataStructures/WaitingList.cpp (+6/-0)
To merge this branch: bzr merge lp:~verifydtapn-contributers/verifydtapn/WaitinglistMemoryleakFix
Reviewer Review Type Date Requested Status
Jiri Srba changes Approve
Jakob Taankvist Approve
Mathias Grund Sørensen Pending
Review via email: mp+136217@code.launchpad.net

Description of the change

Fixed a memory leak in the WaitingList - removing allocated containers
Also changed the way that "stored markings" are saved; they are now counted, instead of returning the size of the hashmap containing the Passed-list (this only shows the number of buckets in the hashmap).

To post a comment you must log in.
Revision history for this message
Jakob Taankvist (jakob-taankvist) :
review: Approve
Revision history for this message
Jiri Srba (srba) :
review: Approve (changes)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/DiscreteVerification/DataStructures/PWList.cpp'
2--- src/DiscreteVerification/DataStructures/PWList.cpp 2012-11-02 08:27:08 +0000
3+++ src/DiscreteVerification/DataStructures/PWList.cpp 2012-11-26 16:39:38 +0000
4@@ -24,6 +24,7 @@
5 return false;
6 }
7 }
8+ stored++;
9 m.push_back(marking);
10 waiting_list->Add(marking);
11 return true;
12
13=== modified file 'src/DiscreteVerification/DataStructures/PWList.hpp'
14--- src/DiscreteVerification/DataStructures/PWList.hpp 2012-07-13 17:50:33 +0000
15+++ src/DiscreteVerification/DataStructures/PWList.hpp 2012-11-26 16:39:38 +0000
16@@ -22,8 +22,8 @@
17 typedef std::vector<NonStrictMarking*> NonStrictMarkingList;
18 typedef google::sparse_hash_map<size_t, NonStrictMarkingList> HashMap;
19 public:
20- PWList() : markings_storage(256000), waiting_list(), discoveredMarkings(0), maxNumTokensInAnyMarking(-1) {};
21- PWList(WaitingList* w_l) : markings_storage(256000), waiting_list(w_l), discoveredMarkings(0), maxNumTokensInAnyMarking(-1) {};
22+ PWList() : markings_storage(256000), waiting_list(), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), stored(0) {};
23+ PWList(WaitingList* w_l) : markings_storage(256000), waiting_list(w_l), discoveredMarkings(0), maxNumTokensInAnyMarking(-1), stored(0) {};
24 virtual ~PWList();
25 friend std::ostream& operator<<(std::ostream& out, PWList& x);
26
27@@ -33,7 +33,7 @@
28 };
29
30 virtual long long Size() const {
31- return markings_storage.size();
32+ return stored;
33 };
34
35 public: // modifiers
36@@ -46,6 +46,8 @@
37 WaitingList* waiting_list;
38 int discoveredMarkings;
39 int maxNumTokensInAnyMarking;
40+private:
41+ unsigned int stored;
42 };
43
44 std::ostream& operator<<(std::ostream& out, PWList& x);
45
46=== modified file 'src/DiscreteVerification/DataStructures/WaitingList.cpp'
47--- src/DiscreteVerification/DataStructures/WaitingList.cpp 2012-07-02 08:09:59 +0000
48+++ src/DiscreteVerification/DataStructures/WaitingList.cpp 2012-11-26 16:39:38 +0000
49@@ -46,6 +46,7 @@
50 void HeuristicStackWaitingList::flushBuffer(){
51 while(!buffer.empty()){
52 stack.push(buffer.top()->marking);
53+ delete buffer.top();
54 buffer.pop();
55 }
56 }
57@@ -104,6 +105,7 @@
58 {
59 WeightedMarking* weighted_marking = queue.top();
60 NonStrictMarking* marking = weighted_marking->marking;
61+ delete queue.top();
62 queue.pop();
63 return marking;
64 }
65@@ -124,6 +126,7 @@
66 HeuristicWaitingList::~HeuristicWaitingList()
67 {
68 while(!queue.empty()){
69+ delete queue.top();
70 queue.pop();
71 }
72 }
73@@ -140,6 +143,7 @@
74 {
75 WeightedMarking* weighted_marking = queue.top();
76 NonStrictMarking* marking = weighted_marking->marking;
77+ delete queue.top();
78 queue.pop();
79 return marking;
80 }
81@@ -152,6 +156,7 @@
82 RandomWaitingList::~RandomWaitingList()
83 {
84 while(!queue.empty()){
85+ delete queue.top();
86 queue.pop();
87 }
88 }
89@@ -167,6 +172,7 @@
90 void RandomStackWaitingList::flushBuffer(){
91 while(!buffer.empty()){
92 stack.push(buffer.top()->marking);
93+ delete buffer.top();
94 buffer.pop();
95 }
96 }

Subscribers

People subscribed via source and target branches