xcsp3team / XCSP3-CPP-Parser

XCSP3 Core Parser in C++
MIT License
19 stars 11 forks source link

Memory leak #20

Open rafa-hub opened 5 years ago

rafa-hub commented 5 years ago

Hi, I would ask you for some help. I read XCSP3 "Knight" files and I generate a matrix with the information of the variables and arrays at the very beginning. After this step, while reading the file I write on this matrix and no new data structures are created, but the program process memory grows and the Operating System shuts down the program process. So I can only work with files under Knights-050-25. I have looked at the stack with GDB, but the stack remains the same and it does not grow while executing the program. Do you have any hint or any help?

By the way, I have noticed that reading Knight files the parameters change order when the index is between 10 and 20, so at the method: buildConstraintPrimitive() with a file, lets say:

x[1] x[8]
  <args> x[1] x[9] </args>
  <args> x[1] x[10] </args>
  <args> x[1] x[11] </args>
  <args> x[1] x[12] </args>

The sequence of values of XVariables x and y are the following: x- 1 : x- 8 x- 1 : x- 9 x- 10 : x 1 x- 11 : x-1 x- 12: x- 1 Any reason for this? Thank you in advance, regards, Rafael

rafa-hub commented 5 years ago

Just to try to add my two cents: Could it be possible that at: void XCSP3Manager::unfoldConstraint(XConstraintGroup group, int i, void (XCSP3Manager::newConstraint)(T *)) memory is allocated but not destroyed until the file is parsed?

audemard commented 5 years ago

I am outside my office this week. I will take a look to this issue next one.

rafa-hub commented 5 years ago

Thank you for your update, and sorry in advance if it is my fault.

audemard commented 5 years ago

Hello For the first part, Did you test the program under valgrind ?

For the second part : By the way, I have noticed that reading Knight files the parameters change order when the index is between 10 and 20, so at the method: buildConstraintPrimitive() with a file, lets say: x[1] x[8] x[1] x[9] x[1] x[10] x[1] x[11] x[1] x[12]

I compute a canonization of the Tree and sort parameters for commutative operators. The sort is done in lexicographic order and then x[2] is greater than x[10]. By the way, this allow to reduce the size of the tree provided by the user.