Additional thanks extend to Daniel Newby for answering my memory usage question (and Martin York for explaining it a bit more). It is definitely the answer I was looking for, but more of my other questions were answered by others.
Thanks everyone
for clearing up all of my concerns. Very pleased to see things running how I expect them to run.
I've run into something that I'm not exactly sure about.
In my program, I'm not using malloc()
or free()
. I'm making instances of my classes with new
and I've made sure each one runs it's destructor
when it's delete
'd, however, there are no free()
calls or even setting their pointers (to things inside a global scope, or other classes) to NULL
or 0
.
What I mean by "I've made sure", is not that I call each destructor. I only use delete to call on the destructor to run, but I have variables that increase by 1 everytime an object is created, and everytime it's destructor is run. This is how I've made sure the amount of objects I created are equal to the amount of destructors called.
Should I be using malloc()
and free()
anyway? Should I be NULL
ing pointers to things that I still want to exist?
A second question is why, when I look at my task manager, does my process never "drop" memory? It used to never stop gaining, and then I started deleting
everything properly. Or so I thought.
Wouldn't free()
or delete
make the memory usage go down?
What practices should I pursue about malloc
'ing and free
'ing memory with linked lists?