We use handles in most cases when opening up a file, for eg:
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:
This handles the memory leaks.
An easy to use handle finder: