-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Hello,
I have a question about memory managing a very specific kind of variable. I have this variable in my model:
template <class T>
...
std::vector<AnObject<T> *> objectList;If I don't memory manage this in my model, I see no error or warning in sim control gui when checkpointing. This is interesting because normally this gui displays such errors or warnings. Since there are no errors/warnings checkpointing seemingly works and generates a checkpoint file. Loading the simulation from this checkpoint also does not display any errors/warnings and seemingly works. But, of course, the logic related to this variable (the vector of object pointers with templates I wrote above) does not work. I would like to provide a sample model code for this here: https://github.com/rendayigit/SampleTrickModel/tree/vector-of-object-pointers-with-templates-issue
Here, the variable I mentioned is the m_connectedInFlows variable in the common/dataFlow.hpp file. This model has two variables to display on trick tv. These are, in.inflow and out.outflow. The outflow variable is incremented every second. And the inflow variable is "connected" to the outflow variable using the logic in common/dataFlow.hpp. This is where the said vector of object pointers with templates comes into play. And connecting a flow means, both variables must show the same value. So before checkpointing, the inflow and outflow variables both keep incrementing as the simulation progresses. But after loading a checkpoint, inflow stops incrementing. I assume that if I successfully memory manage m_connectedInFlows in common/dataFlow.hpp this issue will be fixed. Therefore, I am wondering if it is possible to memory manage such variables? And if so, how would one go about achieving this?
The model code that contains the flow variables:
Trick TV screenshot that shows flow values are equal before checkpointing
Trick TV screenshot that shows flow values are not equal anymore after loading checkpoint
I also would like to note that I am aware of the create_connections routine. We can achieve the same result of passing data between models in this example by using create_connections. But please note that this is just an example, it is the simplest reproducible example for this situation I could come up with :)


