Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if I don't call RegCloseKey on an opened key?

In Windows, what happens to an open HKEY variable if you don't call RegCloseKey before the HKEY goes out of scope? I don't see any errors or warnings, nor any memory leaks when the application closes. MSDN doesn't offer much help, but makes it sound like it somehow uses up resources. Does anyone know what actually happens?

like image 294
bsruth Avatar asked May 01 '09 18:05

bsruth


1 Answers

You orphan a handle, which are a limited (OK, it's a pretty large limit) resource. However, once your app terminates the handle is eventually released by the OS, so the wasted resource is eventually returned to the pool.

It's bad programming practice, though, to allocate something that has limits and not release it when you're done using it.

like image 177
Ken White Avatar answered Oct 18 '22 16:10

Ken White