Memory Leaks when using windows handles

We use handles in most cases when opening up a file, for eg:
void methodA()
int xHandle = 0;
xHandle = open(“c:windowssys.txt”, O_RDONLY);
If we do not close this handle, we are bound to get a memory leak everytime we call this method. You can verify this by opening up task manager and checking the handles this function opens.
The best way to handle this is by closing the handle using:
close(xHandle) method.
This handles the memory leaks.
An easy to use handle finder:

Leave a Reply

Your email address will not be published. Required fields are marked *