Opened 12 years ago

Last modified 12 years ago

#2150 closed defect

external function produces memory leaks — at Version 1

Reported by: Willi Braun Owned by: probably noone
Priority: high Milestone: 1.9.0
Component: Backend Version: trunk
Keywords: Cc: Martin Sjölund

Description (last modified by Willi Braun)

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 (1)

comment:1 by Willi Braun, 12 years ago

Cc: Martin Sjölund added
Description: modified (diff)
Note: See TracTickets for help on using tickets.