Im just wondering what the term Handle count means?
What is "Handle Count"
Collapse
X
-
-
i was just looking for a general meaning. Im looking at some code that is using windows threads. The person that wrote the code said that everytime they call the function abc() they run it on a new thread, and the Handler Count increases. for some reason, this was not expected. They believe that the Handler Count should not have have increased, or should have increased much less then i accually did.
I was not fimilar with the term.
Judging by your definition, it sound to me like the Handler Count increasing is normal. Unfortunatly i dont have more details me self, but i will inquire just how much of an increase we are talking about.Comment
-
When you are inside a function that receives a pointer argument and you need to change the address in the pointer, then you need to delete the memory at the address in the pointer, allocte your new stuff and put the new address in the pointer.
You can't tell from a pointer if:
a) the address in the pointer is to a variable on the stack. If it is and you delete, you crash.
b) the address in the pointer is to a varible on the heap. If it is and you delete, then any copies of that pointer (like in the calling function) are invalid. When you use them, you crash.
So the only safe way to delete a pointer is a) it points to a heap variable and b) you have the last copy of that pointer.
That means, in C, you have to manually keep track of the number of copies of a given pointer. That is, when you call a function, you increment the count. As you leave the function, you decrement the count.The combination of the pointer and the count is called a handle. These would be in a struct.
The count is called a handle (or reference) count.
In C++, you use a handle class: http://bytes.com/forum/thread651599.html.Comment
-
The truth is SpecialKay that handle and handler are very generic terms and their meaning will be and how they are used will be entire dependent on the context they are used in.
In the most generic terms
A handle is an identifier that uniquely identifies some object in a given context without actually allowing direct access to it.
A handler is a piece of code that is run in response to a specific event or message.Comment
-
so the handle count would be refering to the number of pointers to the variables on each thread. and it would be normal for the handle count to increase. However this handle count, should decrease when the thread is finished. And at the end of the program, the handle count should be 0 otherwise we have a memory leak?Comment
-
Originally posted by SpecialKayso the handle count would be refering to the number of pointers to the variables on each thread. and it would be normal for the handle count to increase. However this handle count, should decrease when the thread is finished. And at the end of the program, the handle count should be 0 otherwise we have a memory leak?Comment
-
-
how would someone see this variable? I assue it is built in to VS?Comment
Comment