![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: comparing object attributes with richTextWithOle Topic Summary: Created On: 25-Aug-2004 12:50 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hi,
I am fairly new to this DXL lark, so there may be an easier way to do what I am trying to do, but the way I am trying to do it now is presenting a major problem. I am trying to compare two objects from different baselines of the same module. If the objects are different I copy them into a new module. I have written the following bit of code: bool res=true string attrName for attrName in comparisonAttributes do { string s1 = richTextWithOle o1.attrName string s2 = richTextWithOle o2.attrName if(s1 != s2) { res = false } } return res There are lost of attributes that have been introduced into the model and more than one of them is rich text type. There could also be multiple Oles in a particular attribute. This approach works fine, except that it soon grabs all the memory available, then all the swap space until no memory is left. This comparison is a small part of a larger program, but I have narrowed it down to the two calls to richTextWithOle. As they are held within a for loop, I was expecting the dxl to free the memory from s1 and s2 each time, but this does not seem to be happening. Is there some way to force the memory to be freed, or another way to compare the objects? (It is possible that the objects have different attributes, as they are from different baselines, that is why I loop through the attributes I have found to be common). I thought about using buffers, but I still need to make the call to richTextWithOle to get the string to put in the buffer, so I don't think that would help. I am using DOORS 6 Thanks for any ideas. |
|
![]() |
|
![]() |
|
DXL is really not very good with memory. It could well be that, because you are declaring the two strings inside the loop, memory is being reserved (incrementally) on each pass through the loop. Try declaring them outside the loop, and see if it helps.
Buffers would help, but again you'd want to declare them outside your loop. Probably... Aside If the above is true, it kind of implies we should be doing everything with global variables to conserve memory. Ouch! ![]() ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive Edited: 25-Aug-2004 at 13:06 by Paul Tiplady |
|
![]() |
|
![]() |
|
Buffers are best really. You could try using the following to convert buffers to strings for the comparison:
string tempStringOf(Buffer b) This creates a (very) temporary string that does not persist in the string table. ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
Making the strings global did not help. As the program run, the memory still ramped up until it was all gone.
The memory was not free when the program ended or the modules were shut down. It only freed its memory, when DOORS was closed. Using buffers instead worked fine. I now create 2 buffers before the for loop, set them and compare them directly, i.e. Buffer b1=create Buffer b2=create for ... do { b1=richTextWithOle o1.attrName b2=richTextWithOle o2.attrName if(b1 != b2) { res=false } } delete b1 delete b2 it appears that I do not need to create temporary strings for the compare. |
|
![]() |
|
![]() |
|
Actually now I look into it more closely, using buffers has made no difference what so ever. It appeared that I was not leaking memory any more, but this was due to a bug I introduced that stopped it comparing the oles for a different reason.
As far as I can see, there seems to be no way to identify if an ole within an object has changed, without leaking memory the same size as the ole! I have sent the telelogic support a mail asking for their assistance. |
|
![]() |
|
![]() |
|
I had this problem and discovered this unfortunate reality: if you get the richTextWithOle and then set it to an new object, then retrieve the richTextWithOle from the new and compare it to the old, it is NOT the same. That is:
Text1 = richTextWithOle(o1."Object Text") o2."Object Text" = Text1 Text2 = richTextWithOle(o2."Object Text") if (Text1 !=Text2) then Louie is rignt; so long as o1 contains OLE diagrams. It appears the "OLE" portion of the rich text contains plenty of "empty" space that gets filled with whatever happens to be in that empty window when you retrieve the text. I hate it when that happens. I had some luck plowing through the richText extracting each ole, sending it to a file, then comparing the two files. I think that worked since saving the OLE to a file seems to drastically reduce its size, elliminating the empty windows therein. Yuuuuck, and it didn't save much time. What I ended up doing was this: Compare the two Texts using "richTextNoOle". If they are the same then compare the two object's Last Modified On dates. If they are the same then presume there are no changes to the embedded OLE diagrams otherwise go ahead and waste a lot of time an memory copying the richTextWithOle texts. Another option would be to plow through the History of the source object, looking for "Modify Object" history applying to Object Text. I don't recall if I had any luck getting the LENGTHS of the richTextWithOLE, figuring if the lengths of these were the same (e.g. 875,344 bytes) and the richTextNoOle were the same, then they must be the same. I have a nagging memory that it didn't work (length(Text2) != length(Text1) above. Good luck. - Louie |
|
![]() |
|
![]() |
|
Was there a suggested script posted elsewhere for the possible solution? I tried to hack out a script that compares the Object Text, as suggested, but I'm really struggling with the "Last Modified On" attribute comparison. One of my users wants to format his VRTM so that if a requirement was tested in multiple events, only the last event is included in his VRTM. This corresponds to the "Last Modified On" value, but I'm having no luck putting it all together. //******************************************* if (countOLE1 == 0) if (countOLE2 == 0) if (ole1 != ole2) delete ole1 |
|
![]() |
|
![]() |
|
Your code has a flaw, around the 'else' for the 'if (ole1 != ole2)'. The only statement in the else is the if, and the only statement in the if is the print. the '{ display obj2.Attr }' is back at the outer level of code, and the else after is it meaningless. The line you comment with 'code never gets this far' cannot be exeuted. I think you meant to put the 'if(intOf(...' bit inside the curly brackets for the else, like the snippet below...
Other than that, I have no idea... ![]() ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive Edited: 17-Oct-2006 at 14:27 by Paul Tiplady |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.