I have just fixed the memory leak problems showed by valgrind. Here are some notes:
- To run valgrind efficiently we need to compile the simulator with "-Wall -ggdb3" option.
- The memory leak appears due to some variables are not to be freed. I have already freed it.
- Now the simulator can run normally without memory leak but valgrind also shows the issues about "Conditional jump or move depends on uninitialised value(s)". This issue happens because there are a lot of variables defined in header file without initial value and they will be assigned value on cpp file.
- Also valgrind has an option "--track-origins=yes" to track down where is "Conditional jump or move depends on uninitialised value(s)" occurs. I ran it and got no error, so I guess with the track down option valgrind will know where the variable is assigned value. This is common issue and it is not a memory leak issue.