|
|
|
Re: Memory Leak [message #1018816 is a reply to message #1018329] |
Thu, 14 March 2013 14:23 |
yaroslav Molodkov Messages: 4 Registered: March 2013 |
Junior Member |
|
|
Hi,
I have found piece of code with the problem:
mapping uml::Property::recursiveProcedure(
inout parentNode : mdmi::Bag,
in parentContainerClass : uml::Class,
in someData: Dict(String, Integer),
in someData1: someType1,
...
in someDataN: someTypeN) {
if (some_conditions) then{ // so recursion is not infinite!!!
.......
bag := generateBag(self, parentContainerClass);
self.type.oclAsType(uml::Class).ownedAttribute->
select(attr| (attr.lower >= 0 or attr.name = "templateId"))->map
recursiveProcedure( bag,
self.type.oclAsType(uml::Class),
someData1,
someData2,
...
someDataN);
} endif;
}
It uses recursion to tree traversal UML model. The tree is quite deep (20) and wide.
I think that when we exit the recursive function, memory does not free.
I did some experiments:
1) Changed the number of passed someData arguments. As expected the more arguments the faster memory is lost
2) Use inout instead of in (I hoped we pass reference and do not create a copy of object) did not help
3) Tried to clear object(ofcourse obj := null doesn't work becouse it is input argument) since I've been experimenting with a type Dict
someData->clear();
someData1->clear();
...
someDataN->clear();
memory leak was much slower. but still on.
So what can I do for fix it?
I really do not want to refuse recursion, because the existing script is really big and I will rewrite it too long.
|
|
|
Re: Memory Leak [message #1018868 is a reply to message #1018816] |
Thu, 14 March 2013 15:36 |
Adolfo Sanchez-Barbudo Herrera Messages: 260 Registered: July 2009 |
Senior Member |
|
|
Hi Yaroslav,
Suggestions:
1. If you doesn't need any mapping extension mechanism and any
traceability, I suggest you using a "helper" operation rather than a
"mapping" operation, because the former doesn't deal with traces.
2. Go on the discussion in the open bugzilla [1]. It would be great if
you provide some test cases in which we may reproduce the problem.
3. If something works for you, I'd recommend sharing the solution with
the community ;) (We haven't received any feedback from the suggestion
we did in your other question ;) )
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=403219
Cheers,
Adolfo.
On 14/03/2013 14:23, yaroslav Molodkov wrote:
> Hi,
> I have found piece of code with the problem:
>
> mapping uml::Property::recursiveProcedure(
> inout parentNode : mdmi::Bag,
> in parentContainerClass : uml::Class,
> in someData: Dict(String, Integer),
> in someData1: someType1,
> ... in someDataN: someTypeN) {
> if (some_conditions) then{ // so recursion is not infinite!!!
> .......
> bag := generateBag(self, parentContainerClass);
> self.type.oclAsType(uml::Class).ownedAttribute->
> select(attr| (attr.lower >= 0 or attr.name = "templateId"))->map
> recursiveProcedure( bag, self.type.oclAsType(uml::Class),
> someData1,
> someData2,
> ...
> someDataN);
> } endif;
> }
>
> It uses recursion to tree traversal UML model. The tree is quite deep
> (20) and wide.
> I think that when we exit the recursive function, memory does not free.
> I did some experiments:
> 1) Changed the number of passed someData arguments. As expected the more
> arguments the faster memory is lost
> 2) Use inout instead of in (I hoped we pass reference and do not create
> a copy of object) did not help
> 3) Tried to clear object(ofcourse obj := null doesn't work becouse it is
> input argument) since I've been experimenting with a type Dict
> someData->clear();
> someData1->clear();
> ...
> someDataN->clear();
> memory leak was much slower. but still on.
>
> So what can I do for fix it? I really do not want to refuse recursion,
> because the existing script is really big and I will rewrite it too long.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03217 seconds