Opened 12 years ago
Closed 12 years ago
#2150 closed defect (fixed)
Copy back data from external integer arrays
Reported by: | Willi Braun | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | 1.9.0 |
Component: | Backend | Version: | trunk |
Keywords: | Cc: | Martin Sjölund |
Description (last modified by )
following model generates memory leaks for Integer values.
system("echo \"void extIntegerArray(int* a, int n, int* out){int i;for(i=0;i<n;i++){out[i] = a[i]+i;}}\" > ExtIntegerArrayFunc.c"); loadString(" function extIntegerArray input Integer x[:]; input Integer s; output Integer y[size(x,1)]; external \"C\" extIntegerArray(x,s,y) annotation(Library=\"libExtIntegerArrayFunc1_ext.a\"); end extIntegerArray; model A function extIntArray input Integer x[:]; input Integer s; output Integer y[size(x,1)]; algorithm y := extIntegerArray(x,s); end extIntArray; Integer ints[:] = {integer(2*time),integer(1*time),3,5,7,8,3}; Integer ou1[size(ints,1)]; equation ou1 = extIntArray(ints,size(ints,1)); end A;"); getErrorString(); system("gcc -c -o libExtIntegerArrayFunc1_ext.a ExtIntegerArrayFunc.c"); simulate(A, stopTime=0.1, numberOfIntervals=2); system("valgrind ./A"); getErrorString();
it's the usage of data_of_integer_array in util/inter_array.h that produces memory leaks.
Change History (3)
comment:1 by , 12 years ago
Cc: | added |
---|---|
Description: | modified (diff) |
comment:2 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
Summary: | external function produces memory leaks → external function does not produce memory leaks |
comment:3 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Summary: | external function does not produce memory leaks → Copy back data from external integer arrays |
Fixed in r15872
Note:
See TracTickets
for help on using tickets.
A memory leak is when we allocate memory that we cannot reclaim. In this case, we assign to one piece of allocated memory, and subsequently free it without copying it to the correct place.
I have a fix in place; running the testsuite overnight.