I’m pretty sure this is a copy constructor problem. The std::vector makes a copy of the TestVarClass object when it adds it to the vector. The problem is that this implementation can’t be copied using the default copy constructor or operator, because Particle.variable will continue to point to the old spot in memory, which will then get freed, causing the weird values.
I believe @rickkas7 is correct here. Note too that std::vector can also call the copy constructor when it runs out of storage and needs to grow the vector–it basically allocates a bigger block and copy constructs all the current elements into it before adding the newest one during push_back.
When you call Particle.variable() are you registering a memory location as a cloud accessible variable, so it makes sense that the location of the variable in memory cannot change if you want the variable to continue to work.