What is the difference looking from memory menagement site between using one vector class member for all temp vectors used in functions:
class A
{
private:
vector<Type> m_vector;
}
void fnc()
{
m_vector.clear();
m_vector.push_back();
//further operations on vector
}
and creating temp vectors inside of functions:
void fnc()
{
vector<Type> vector;
//further operations on vector
}
I suppose first option results in less memory fragmentation, cause we are doing one allocation and using this area, and in second case we are allocating memory for vectors in different functions which results in memory fragmentation.
What are the pros and cons of this vector usages? Which one should I use when I have class which needs many vectors in its functions? And which one is better looking from memory menagement site?