Once in a while I'm blind as a bat, but I just realized that there are numerous DXL data structures that should be deleted when no longer needed. I wonder if we could get such a list, including ones that should not. |
Re: Deleting structures
Well the stuff that can be created and deleted is all the internal data structures of DXL (that are not bound to persisting data in DOORS) create/delete : Array, Buffer, Skip, DxlObject, Regexp, OleAutoArgs, Stat create/oleCloseAutoObject: OleAutoObj create / destroy : DB client, server / delete : IPC Probably also: HTTPBody, HTTPHeader, HTTPHeaderEntry,
Module, Item, Project, View, ...
Baseline, Column, (possibly more?), ...
// targetVersion creates a new ModuleVersion ModuleVersion mv = targetVersion theLink // assignment in declaration, will not create a copy of the ModuleVersion delete mv // free the ModuleVersion, everything is fine ModuleVersion mv = null // this creates a copy of the targetVersion result, and will leak the targetVersion result mv = targetVersion theLink // calls the ::=(ModuleVersion &, ModuleVersion) copy-assignment operator! delete mv // delete only the copy
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Deleting structures Mathias Mamsch - Fri Jun 01 16:08:39 EDT 2012
Well the stuff that can be created and deleted is all the internal data structures of DXL (that are not bound to persisting data in DOORS) create/delete : Array, Buffer, Skip, DxlObject, Regexp, OleAutoArgs, Stat create/oleCloseAutoObject: OleAutoObj create / destroy : DB client, server / delete : IPC Probably also: HTTPBody, HTTPHeader, HTTPHeaderEntry,
Module, Item, Project, View, ...
Baseline, Column, (possibly more?), ...
// targetVersion creates a new ModuleVersion ModuleVersion mv = targetVersion theLink // assignment in declaration, will not create a copy of the ModuleVersion delete mv // free the ModuleVersion, everything is fine ModuleVersion mv = null // this creates a copy of the targetVersion result, and will leak the targetVersion result mv = targetVersion theLink // calls the ::=(ModuleVersion &, ModuleVersion) copy-assignment operator! delete mv // delete only the copy
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
I see ModuleProperties didn't make your lists. Are there just a couple, or perhaps many others that we need to deal with? Can we -- meaning you -- create a "void delete(&ModuleProperties)" function?
ModuleVersion targetVersionOfLink(Link lnk)
{ // Get the ModuleVersion of the target of the link
// Caller should delete the mv when finished with it
ModuleVersion mv = targetVersion(lnk)
return(mv)
} // end targetVersionOfLink()
ModuleVersion sourceVersionOfLink(Link lnk) ditto
|
Re: Deleting structures llandale - Mon Jun 04 17:24:25 EDT 2012
I see ModuleProperties didn't make your lists. Are there just a couple, or perhaps many others that we need to deal with? Can we -- meaning you -- create a "void delete(&ModuleProperties)" function?
ModuleVersion targetVersionOfLink(Link lnk)
{ // Get the ModuleVersion of the target of the link
// Caller should delete the mv when finished with it
ModuleVersion mv = targetVersion(lnk)
return(mv)
} // end targetVersionOfLink()
ModuleVersion sourceVersionOfLink(Link lnk) ditto
I answered the ModuleVersion thing here: https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14832712� print "Allocated Objects Before Declaration: " allocatedObjects() "\n" ViewDef vd = createPublic() print "Allocated Objects After Declaration: " allocatedObjects() "\n"
if (null current Object) error "Please run this script from a module with an object!" print "Allocated Objects Before Declaration: " allocatedObjects() "\n" Attr__ x = (current Object)."Object Text" // allocate the Attr__ print "Allocated Objects After Declaration: " allocatedObjects() "\n" string s = x // assignment will free the Attr__ print "Allocated Objects After Assignment: " allocatedObjects() "\n"
|
Re: Deleting structures Mathias Mamsch - Thu Jun 07 10:16:12 EDT 2012
I answered the ModuleVersion thing here: https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14832712� print "Allocated Objects Before Declaration: " allocatedObjects() "\n" ViewDef vd = createPublic() print "Allocated Objects After Declaration: " allocatedObjects() "\n"
if (null current Object) error "Please run this script from a module with an object!" print "Allocated Objects Before Declaration: " allocatedObjects() "\n" Attr__ x = (current Object)."Object Text" // allocate the Attr__ print "Allocated Objects After Declaration: " allocatedObjects() "\n" string s = x // assignment will free the Attr__ print "Allocated Objects After Assignment: " allocatedObjects() "\n"
I use "ModuleProperties" to query the "Last Modified On" date of the module, figuring to ignore it if more than 8 days old. I notice memory useage increases rather dramatically and I presume it to be the large number of ModuleProperties allocated units. Can you create a "void delete(&ModuleProperties)" function? -Louie |
Re: Deleting structures llandale - Sat Nov 10 12:54:57 EST 2012 http://www.ibm.com/developerworks/forums/click.jspa?searchID=-1&messageID=14849772 Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Deleting structures Mathias Mamsch - Sat Nov 10 13:36:15 EST 2012 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
You know I have an unreasonable resistance to outside-the-box voodoo. Never-the-less I ran your code in that post; wrote my own "string" instead of "Buffer" version; and wrote a test to see how long each takes along with using the normal non-eval version.
string NameMod_Target = "/Testing/Document1"
string Results_Expected = "Testing_" // Prefix of module
pragma runLim, 0
//******************************************
string fModAttr_GetValue(ModName_ in_mn, string in_NameAttr)
{ // Get the module attr value without opening the module
// This is done using ModuleProperties but since there is no delete for
// that structure, this function uses "eval_" to do it
// presuming the structure is removed after eval_() ends
if (null in_mn or null in_NameAttr) then return("") // Program input error
string ErrMess, EvalResult = ""
ModuleVersion mv = moduleVersion (in_mn)
if (null mv)
{ print "fModAttr_GetValue(); bad moduleVersion\n"
return("")
}
string EvalCode = "
ModName_ mn = addr_ " (int (addr_ in_mn)) "
ModuleVersion mv = addr_ " (int (addr_ mv)) "
ModuleProperties mp
getProperties (mv, mp)
return_(mp.\"" in_NameAttr "\" \"\")
" // end string EvalCode
// print "Evaluating EvalCode: " EvalCode "\n\n"
ErrMess = checkDXL(EvalCode)
if (!null ErrMess)
{ print "fModAttr_GetValue(); checkDXL() error [" ErrMess "\t]... for code:" EvalCode "\n"
}
else
{ noError()
EvalResult = eval_(EvalCode)
ErrMess = lastError()
if (!null ErrMess)
{ print "fModAttr_GetValue() eval_() error [" ErrMess "\t]... for code:" EvalCode "\n"
EvalResult = ""
}
}
delete(mv)
// print "EvalResult [" EvalResult "]\n"
return EvalResult
} // end fModAttr_GetValue()
//******************************************
Buffer readModuleProperty (ModName_ mn, string aName) {
Buffer buf = create()
string sCode = "
ModName_ mn = addr_ " ((addr_ mn) int) "
Buffer buf = addr_ " ((addr_ buf) int) "
ModuleVersion mv = moduleVersion mn
ModuleProperties mp
getProperties (mv, mp)
buf = mp.\"" aName "\"
"
// print "Evaluating sCode: " sCode "\n\n"
noError(); string result = eval_ sCode; string errMsg = lastError()
if (!null result || !null errMsg) { delete buf; buf = null Buffer; print errMsg }
return buf
}
void DoTest_Buffer(int in_NumLoops)
{
Buffer x
ModName_ mn = module(NameMod_Target)
int i, TimeStart = getTickCount_()
for (i=0; i<in_NumLoops; i++)
{ x = readModuleProperty(mn, "Prefix")
if (!null x) delete x
}
print "\t" (getTickCount_() - TimeStart) "ms\tDoTest_Buffer\n"
x = readModuleProperty(mn, "Prefix")
if (!null x)
{ if (tempStringOf(x) != Results_Expected) print "\t\tBAD results [" x "]\n"
delete x
}
else print "\t\tNull buff results\n"
}
void DoTest_String(int in_NumLoops)
{
string x
ModName_ mn = module(NameMod_Target)
int i, TimeStart = getTickCount_()
for (i=0; i<in_NumLoops; i++)
{ x = fModAttr_GetValue(mn, "Prefix")
}
print "\t" (getTickCount_() - TimeStart) "ms\tDoTest_String\n"
if (x != Results_Expected) print "\t\tBAD results [" x "]\n"
}
void DoTest_Normal(int in_NumLoops)
{
string x
ModName_ mn = module(NameMod_Target)
ModuleVersion mv
ModuleProperties mp
// mv = moduleVersion mn
// getProperties (mv, mp)
int i, TimeStart = getTickCount_()
for (i=0; i<in_NumLoops; i++)
{ mv = moduleVersion mn
getProperties (mv, mp)
x = mp."Prefix"
}
print "\t" (getTickCount_() - TimeStart) "ms\tDoTest_Normal\n"
if (x != Results_Expected) print "\t\tBAD results [" x "]\n"
}
void DoAllTests(int in_NumLoops)
{
print "Test: #Loops: " in_NumLoops "\n"
DoTest_Normal(in_NumLoops)
DoTest_Buffer(in_NumLoops)
DoTest_String(in_NumLoops)
DoTest_Normal(in_NumLoops)
}
if (false)
{ // Create a bunch of structures. 100,000 took about 2 minutes
int i
Buffer x
for (i=0; i<30000; i++) x = create()
}
DoAllTests(100) // 100 loops
Results:
Test: #Loops: 100
1547ms DoTest_Normal
1453ms DoTest_Buffer
1469ms DoTest_String
1594ms DoTest_Normal
|
Re: Deleting structures llandale - Sun Nov 11 14:34:18 EST 2012
You know I have an unreasonable resistance to outside-the-box voodoo. Never-the-less I ran your code in that post; wrote my own "string" instead of "Buffer" version; and wrote a test to see how long each takes along with using the normal non-eval version.
string NameMod_Target = "/Testing/Document1"
string Results_Expected = "Testing_" // Prefix of module
pragma runLim, 0
//******************************************
string fModAttr_GetValue(ModName_ in_mn, string in_NameAttr)
{ // Get the module attr value without opening the module
// This is done using ModuleProperties but since there is no delete for
// that structure, this function uses "eval_" to do it
// presuming the structure is removed after eval_() ends
if (null in_mn or null in_NameAttr) then return("") // Program input error
string ErrMess, EvalResult = ""
ModuleVersion mv = moduleVersion (in_mn)
if (null mv)
{ print "fModAttr_GetValue(); bad moduleVersion\n"
return("")
}
string EvalCode = "
ModName_ mn = addr_ " (int (addr_ in_mn)) "
ModuleVersion mv = addr_ " (int (addr_ mv)) "
ModuleProperties mp
getProperties (mv, mp)
return_(mp.\"" in_NameAttr "\" \"\")
" // end string EvalCode
// print "Evaluating EvalCode: " EvalCode "\n\n"
ErrMess = checkDXL(EvalCode)
if (!null ErrMess)
{ print "fModAttr_GetValue(); checkDXL() error [" ErrMess "\t]... for code:" EvalCode "\n"
}
else
{ noError()
EvalResult = eval_(EvalCode)
ErrMess = lastError()
if (!null ErrMess)
{ print "fModAttr_GetValue() eval_() error [" ErrMess "\t]... for code:" EvalCode "\n"
EvalResult = ""
}
}
delete(mv)
// print "EvalResult [" EvalResult "]\n"
return EvalResult
} // end fModAttr_GetValue()
//******************************************
Buffer readModuleProperty (ModName_ mn, string aName) {
Buffer buf = create()
string sCode = "
ModName_ mn = addr_ " ((addr_ mn) int) "
Buffer buf = addr_ " ((addr_ buf) int) "
ModuleVersion mv = moduleVersion mn
ModuleProperties mp
getProperties (mv, mp)
buf = mp.\"" aName "\"
"
// print "Evaluating sCode: " sCode "\n\n"
noError(); string result = eval_ sCode; string errMsg = lastError()
if (!null result || !null errMsg) { delete buf; buf = null Buffer; print errMsg }
return buf
}
void DoTest_Buffer(int in_NumLoops)
{
Buffer x
ModName_ mn = module(NameMod_Target)
int i, TimeStart = getTickCount_()
for (i=0; i<in_NumLoops; i++)
{ x = readModuleProperty(mn, "Prefix")
if (!null x) delete x
}
print "\t" (getTickCount_() - TimeStart) "ms\tDoTest_Buffer\n"
x = readModuleProperty(mn, "Prefix")
if (!null x)
{ if (tempStringOf(x) != Results_Expected) print "\t\tBAD results [" x "]\n"
delete x
}
else print "\t\tNull buff results\n"
}
void DoTest_String(int in_NumLoops)
{
string x
ModName_ mn = module(NameMod_Target)
int i, TimeStart = getTickCount_()
for (i=0; i<in_NumLoops; i++)
{ x = fModAttr_GetValue(mn, "Prefix")
}
print "\t" (getTickCount_() - TimeStart) "ms\tDoTest_String\n"
if (x != Results_Expected) print "\t\tBAD results [" x "]\n"
}
void DoTest_Normal(int in_NumLoops)
{
string x
ModName_ mn = module(NameMod_Target)
ModuleVersion mv
ModuleProperties mp
// mv = moduleVersion mn
// getProperties (mv, mp)
int i, TimeStart = getTickCount_()
for (i=0; i<in_NumLoops; i++)
{ mv = moduleVersion mn
getProperties (mv, mp)
x = mp."Prefix"
}
print "\t" (getTickCount_() - TimeStart) "ms\tDoTest_Normal\n"
if (x != Results_Expected) print "\t\tBAD results [" x "]\n"
}
void DoAllTests(int in_NumLoops)
{
print "Test: #Loops: " in_NumLoops "\n"
DoTest_Normal(in_NumLoops)
DoTest_Buffer(in_NumLoops)
DoTest_String(in_NumLoops)
DoTest_Normal(in_NumLoops)
}
if (false)
{ // Create a bunch of structures. 100,000 took about 2 minutes
int i
Buffer x
for (i=0; i<30000; i++) x = create()
}
DoAllTests(100) // 100 loops
Results:
Test: #Loops: 100
1547ms DoTest_Normal
1453ms DoTest_Buffer
1469ms DoTest_String
1594ms DoTest_Normal
Of course if you expect DXL programs with lots of allocations the string version will exceed the buffer version in its performance. The error checking could either be done in the eval or you put some string in front of the result and check for that string. So that is no real reason to use the buffer variant. So I guess you will be fine using the string variant, as long as you don't query very long richText values (if that is even possible). Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Deleting structures Mathias Mamsch - Sun Nov 11 15:41:42 EST 2012 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |