问题描述:

I have a program that loads an image from a file with DirectX using D3DXCreateTextureFromFileEx(...), and I forgot to add the image->Release() function to the end of the program during the first test. I know that not releasing the image is bad, but what exactly happens (and is the damage permanent)?

网友答案:

I never used DirectX, but this sounds like a simple resource leak: you end up with having allocated textures that can never be reclaimed by the OS while the program is running. In this case, you're "just" cluttering video memory. The same kind of leak exists with memory allocation (calling new but never delete or calling malloc but never free, for instance) or file pointers (never closing opened file pointers).

Any resource still owned by a program is reclaimed by the OS once it's stopped, so it's nothing permanent, and causes problem "just" for as long as your program runs. However, if you don't reclaim resources while your program is running, you might end up causing problems to your program because there's no more room for what it needs, or to other programs that would need to use the resources you're wasting.

网友答案:

Don't worry, windows cleans up your mess. Windows always free resources when an process exists, regardless off what the process handled it.

相关阅读:
Top