I have prepared a class for storing data retrieved from db, and let’s say I have 10 vars in it. What if I will reuse this class for different views and each view will use a different quantity of variables.
tableViewCell will pop-up 3 vars.
View1 will pop-up 6 vars.
View2 will pop-up 10 vars.
Will the unused data cause memory leaks?
A memory leak only happens when you delete all pointers to the memory before freeing it. If you reuse your data structure, you might have some unused memory, but it won’t be a leak unless you never free it when the pointers go away (leaving you no way to free it ever again).