Hi, |
Re: Memory Leak when looping over out-links of objects
Memory leaks is DOORS is a complicated issue. Most of the time it is not obvious where the memory is leaked. When interating over links in DOORS, e.g. most of the time people forget to free the 'ModuleVersion':
Link L
for L in o->"*" do {
ModuleVersion mv = targetVersion L
load (L, false)
// delete mv
Object oTgt = target L
...
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Memory Leak when looping over out-links of objects Mathias Mamsch - Thu May 31 20:46:54 EDT 2012
Memory leaks is DOORS is a complicated issue. Most of the time it is not obvious where the memory is leaked. When interating over links in DOORS, e.g. most of the time people forget to free the 'ModuleVersion':
Link L
for L in o->"*" do {
ModuleVersion mv = targetVersion L
load (L, false)
// delete mv
Object oTgt = target L
...
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Many thanks for your reply. We did not realise that ModuleVersion needed to be freed. This isn't documented particularly well in the DXL Reference Manual (I don't think it's mentioned). And the DXL Reference Manual gives several examples using ModuleVersions where they're not deleted! Now that we are deleting the ModuleVersions, we think this has improved the way our script is performing. We suspect there might also be a problem when we switch a module into 'open for edit' that we already have 'open for read' - but we haven't had chance to properly investigate these suspicions yet, Thanks again, Mike |
Re: Memory Leak when looping over out-links of objects mikebleazard - Fri Jun 01 19:48:00 EDT 2012
Hi Mike, ... ModuleVersion mv = targetVersion L // no leak delete mv ... // --------------------- snip -------------------- ModuleVersion mv = null ... mv = targetVersion L // Leak! delete mv ...
ModuleVersion ::= (ModuleVersion &, ModuleVersion)
int *::+(int *ptr1, int ofs) { int *ptr2 = ptr1; ptr2+=ofs; return ptr2 }
int *::@(int *ptr, int ofs) { int ad = *(ptr + ofs); int *ptr2 = addr_ ad; return ptr2 }
int *ccp () {
DB x = create ""
int *p = addr_ x; int *r = p @ 48
destroy x
return r
}
int *mbn (int *cc) { return cc @ 0x74 }
int *dp (int *n) { return n @ 0 }
int *nn (int *n) { return n @ 8 }
int allocatedObjects() {
int cnt = 0
int *mb = mbn ccp()
while (!null mb) { mb = nn mb; cnt++ }
return cnt
}
// ------------- snip ----------------
print "Allocated Objects at start of DXL code:"
print allocatedObjects()
Buffer buf = create()
print "Allocated Objects after Allocating a Buffer:"
print allocatedObjects()
delete buf
print "Allocated Objects after Freeing the Buffer:"
print allocatedObjects()
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Memory Leak when looping over out-links of objects Mathias Mamsch - Sat Jun 02 17:43:56 EDT 2012
Hi Mike, ... ModuleVersion mv = targetVersion L // no leak delete mv ... // --------------------- snip -------------------- ModuleVersion mv = null ... mv = targetVersion L // Leak! delete mv ...
ModuleVersion ::= (ModuleVersion &, ModuleVersion)
int *::+(int *ptr1, int ofs) { int *ptr2 = ptr1; ptr2+=ofs; return ptr2 }
int *::@(int *ptr, int ofs) { int ad = *(ptr + ofs); int *ptr2 = addr_ ad; return ptr2 }
int *ccp () {
DB x = create ""
int *p = addr_ x; int *r = p @ 48
destroy x
return r
}
int *mbn (int *cc) { return cc @ 0x74 }
int *dp (int *n) { return n @ 0 }
int *nn (int *n) { return n @ 8 }
int allocatedObjects() {
int cnt = 0
int *mb = mbn ccp()
while (!null mb) { mb = nn mb; cnt++ }
return cnt
}
// ------------- snip ----------------
print "Allocated Objects at start of DXL code:"
print allocatedObjects()
Buffer buf = create()
print "Allocated Objects after Allocating a Buffer:"
print allocatedObjects()
delete buf
print "Allocated Objects after Freeing the Buffer:"
print allocatedObjects()
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Due to a question in this post: https://www.ibm.com/developerworks/forums/thread.jspa?threadID=430318&tstart=0 if (null current Module) error "Please run this script from a module!" print "Allocated Objects Before Assigning in Declaration: " allocatedObjects() "\n" ModuleVersion mv = moduleVersion current print "Allocated Objects After Assigning in Declaration " allocatedObjects() "\n" delete mv print "Allocated Objects After Deleting the assignment in Declaration " allocatedObjects() "\n" print "\n" print "Allocated Objects Before Assigning Outside of Declaration: " allocatedObjects() "\n" ModuleVersion mv2 mv2 = moduleVersion current print "Allocated Objects After Assigning Outside of Declaration " allocatedObjects() "\n" delete mv2 print "Allocated Objects After Deleting the assignment Outside of Declaration " allocatedObjects() "\n"
Allocated Objects Before Assigning in Declaration: 0 Allocated Objects After Assigning in Declaration 1 Allocated Objects After Deleting the assignment in Declaration 0 Allocated Objects Before Assigning Outside of Declaration: 0 Allocated Objects After Assigning Outside of Declaration 2 Allocated Objects After Deleting the assignment Outside of Declaration 1
ModuleVersion mv = targetVersionOfLink L // no leak ModuleVersion mv2; mv2 = targetVersionOfLink L // leak
ModuleVersion ::<- (ModuleVersion &mv, ModuleVersion mv2) {
int &ref = addr_ mv // cast to integer
int val = addr_ mv2 // cast to integer
ref = val // use integer assignment to make a reference copy ...
return mv2
}
ModuleVersion mv3
mv3 <- moduleVersion current
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|