![]() |
|
#1
|
|||
|
|||
Memory de-allocation during debuggingDear experts,
It has happened many times to me that during debugging, the program experience some exception that asks the me to terminate debugging. However, if this happens after I have just allocated memory to an object but did not reach the line of de-allocation, what will the debugger do? Will it de-allocate the memory itself? The debugger I am using is Visual C++. NET and the OS I am on is Windows XP. What should I do if it does not automatically de-allocate the memoty? Thanks in advance! Kind Regards, David |
|
#2
|
||||
|
||||
Re: Memory de-allocation during debuggingQuote:
Quote:
Quote:
__________________
Age is unimportant -- except in cheese |
|
#3
|
||||
|
||||
Re: Memory de-allocation during debuggingBasically, windows XP will de-allocate the memory allocated by your application.
But, and this is a big but : Don't count on it ! I personally coded a memory handling set of functions, that allow me to keep an eye on my allocations and free them when needed. If you worrie about your applications crashing and leaving "left-overs" behind, then perhaps you could build yourself such a module. Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#4
|
|||
|
|||
Re: Memory de-allocation during debuggingThanks for your posts, guys.
WaltP, actually, I am thinking of ways of de-allocating memory without reboot, because I always open a few applications and don't want to close and open them again. Any suggestions? kobi hikri, do you mean the set of functions like _CrtDumpMemoryLeaks()? Or do you mean you have written a set of functions that will independently save the memory state information before debugging and after forced termination? So that it knows which memory to de-allocate? Can you elaborate? Thanks! |
|
#5
|
||||
|
||||
Re: Memory de-allocation during debuggingQuote:
Hey. I mean I wrote my own versions of malloc, calloc, realloc, and free. My versions use the original functions, but keep track of the memory allocated and de-allocated. Let me know if you have interest in this code (there are some bugs that I didn't fix yet, with the reallocation process - So I'd prefer not post it). Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#6
|
||||
|
||||
Re: Memory de-allocation during debuggingKobi,
Quote:
Also, Senior members can help us fix the bug. Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#7
|
|||
|
|||
Re: Memory de-allocation during debuggingHi, Kobi,
Yeah, it will be great if you could share the code with us. Can I request for a copy of it? Many thanks! Are you able to upload it, or do you need my email address? Best, David |
|
#8
|
||||
|
||||
Re: Memory de-allocation during debuggingWell, here it is ...
But know it is not completed and there are some bugs ! The main problem right now is with the mrealloc function (it fails in the part where it calls the function to remove an item from the memory pool), as you could see for yourself MemoryHandling.h CPP / C++ / C Code:
MemoryHandling.c CPP / C++ / C Code:
The memory "m"reallocation problem is something I'm hoping to fix as soon as I could spare time. Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#9
|
|||
|
|||
Re: Memory de-allocation during debuggingQuote:
I don't know if there are other problems, but: CPP / C++ / C Code:
Note 1: the pointer p might no longer point to memory that you own. Note 2: this malloc could give the same memory region that used to be p. Note 3: now you are screwed (since you will be de-referencing pointers in a block of memory that you no longer own, and you don't know what their values are). I put some printfs after malloc() and realloc() calls and discovered that the condition in Note 2 occurred with your example program, so, well ..., see Note 3. Other compilers and/or other data sizes could give different results that appear to work under some conditions, but this is a fatal bug. (gcc Linux) Regards, Dave |
|
#10
|
||||
|
||||
Re: Memory de-allocation during debuggingQuote:
Yeah, This is what I understood from another question I asked here on the forum (Another thread, if you remeber - I asked something about realloc and you answered me). Didn't fix that yet ... But will fix it soon (hopefully). Kobi. __________________
It's actually a one time thing (it just happens alot). |
Recent GIDBlog
Toyota - 2008 August Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Memory allocation issue | kobi_hikri | C++ Forum | 6 | 27-Oct-2005 12:16 |
| Pointer Usage in C++: Beginner to Advanced | varunhome | C++ Forum | 0 | 19-Aug-2005 09:25 |
| [Tutorial] Pointers in C (Part I) | Stack Overflow | C Programming Language | 1 | 08-Apr-2005 18:35 |
| 3D array dynamic memory allocation | cjwatchdog | C Programming Language | 3 | 20-Feb-2004 15:27 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The