| View previous topic :: View next topic |
| Author |
Message |
supercharger Advanced Cheater
Reputation: 0
Joined: 06 Aug 2009 Posts: 61
|
Posted: Fri Jul 29, 2011 12:49 am Post subject: will memory leak be eliminated when a process is terminated? |
|
|
say i allocate some memory space (0x7f00000~7f10000) in a process.
if i don't free the memory space before i hit Alt+F4 to terminated the process, will the memory space be freed from the physical memory?
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Fri Jul 29, 2011 3:02 am Post subject: |
|
|
alt-f4 closes a window by default, not exits a process. if you are just closing a window, perhaps not. if you are killing the whole process, the OS will deal with freeing memory that you forgot to free
you're also confusing physical memory with what you're accessing which is virtual memory. depending on what is currently paged in, there is a chance the memory you are referring to is on physical memory. if it's not paged in right now then it would be on disk
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Fri Jul 29, 2011 12:21 pm Post subject: |
|
|
Look into using smart pointers if you are worried about allocations not being free'd as well. You can also use memory profiling tools to ensure your app is cleaning up properly after it's being told to exit.
_________________
- Retired. |
|
| Back to top |
|
 |
supercharger Advanced Cheater
Reputation: 0
Joined: 06 Aug 2009 Posts: 61
|
Posted: Sat Jul 30, 2011 12:09 am Post subject: |
|
|
thanks.
in my case, it's a game that has only 1 window. when i hit Alt+F4, the whole process is closed.
i do use pointers when i allocate the memory space, and i can free the space by a function within the process.
what i worry about is that if i don't execute the "free" function before closing the game, the memory space is still ocupied until i reboot the PC. if that's true, i will use up the memory after i run the game dozens of times.
i hope WinXP cleans up everything when it kills a process.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Jul 30, 2011 5:05 am Post subject: |
|
|
| it will clean it up, yes
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sat Jul 30, 2011 5:41 am Post subject: |
|
|
| Is there any way i can minitor when memory is being allocated/deallocated, so i can see if/where im leaking?
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sat Jul 30, 2011 6:25 am Post subject: |
|
|
| you need to search for memory profiler tools. unfortunately i don't code c++ much so can't recommend one
|
|
| Back to top |
|
 |
|