Click here to Skip to main content
15,887,985 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: LVN_ONITEMCHANGING Pin
paper6726-Sep-07 6:36
paper6726-Sep-07 6:36 
QuestionRe: LVN_ONITEMCHANGING Pin
Mark Salsbery26-Sep-07 7:12
Mark Salsbery26-Sep-07 7:12 
AnswerRe: LVN_ONITEMCHANGING Pin
paper6726-Sep-07 7:44
paper6726-Sep-07 7:44 
GeneralRe: LVN_ONITEMCHANGING Pin
Mark Salsbery26-Sep-07 8:05
Mark Salsbery26-Sep-07 8:05 
QuestionRe: LVN_ONITEMCHANGING Pin
Nelek26-Sep-07 20:25
protectorNelek26-Sep-07 20:25 
Questionoperator delete Pin
Waldermort26-Sep-07 4:13
Waldermort26-Sep-07 4:13 
AnswerRe: operator delete Pin
Maximilien26-Sep-07 4:25
Maximilien26-Sep-07 4:25 
AnswerRe: operator delete [modified] Pin
Randor 26-Sep-07 5:26
professional Randor 26-Sep-07 5:26 
Here is what happens when you call operator new when _DEBUG is defined. (As I understand it)

1.) _malloc_dbg() is invoked and your size_t is passed through.
2.) An object is created of struct type _CrtMemBlockHeader.
3.) The memory you have requested is allocated and memset() to 0xCD. (C = Clean)
4.) 4 bytes on both sides of the memory you requested are memset() to 0xFD (F = Fence)
5.) A pointer to the _CrtMemBlockHeader is added to an internal linked list for tracking.
6.) A pointer to the memory you requested is returned.

When the memory is released here is what happens:

1.) _free_dbg is invoked and passed the address.
2.) The debug heap manager walks through the linked list and finds the pointer to the CrtMemBlockHeader struct.
3.) Checks are made on both sizes of the memory you requested to make sure the Fence 0xFD is still there.
4.) The memory location is memset() to 0xDD (D = Dead)
5.) The _CrtMemBlockHeader is marked as freed in the heap managers linked list. But the struct remains in memory.

Upon application termination the entire linked list is walked and inspected for memory which was not freed or missing its fence.

Hope this helps you,
-Randor (David Delaune)
GeneralRe: operator delete Pin
Waldermort26-Sep-07 6:23
Waldermort26-Sep-07 6:23 
Questionsyatem level Hooks related issue Pin
Sharad Goyal26-Sep-07 4:00
Sharad Goyal26-Sep-07 4:00 
AnswerRe: syatem level Hooks related issue Pin
ThatsAlok26-Sep-07 19:35
ThatsAlok26-Sep-07 19:35 
Questionthe function FILE Pin
youbo26-Sep-07 3:01
youbo26-Sep-07 3:01 
AnswerRe: the function FILE Pin
jhwurmbach26-Sep-07 3:34
jhwurmbach26-Sep-07 3:34 
AnswerRe: the function FILE Pin
toxcct26-Sep-07 3:40
toxcct26-Sep-07 3:40 
Questiongraph include? Pin
srvsah26-Sep-07 2:35
srvsah26-Sep-07 2:35 
AnswerRe: graph include? Pin
David Crow26-Sep-07 2:37
David Crow26-Sep-07 2:37 
GeneralRe: graph include? Pin
srvsah26-Sep-07 2:40
srvsah26-Sep-07 2:40 
GeneralRe: graph include? Pin
David Crow26-Sep-07 2:44
David Crow26-Sep-07 2:44 
GeneralRe: graph include? Pin
srvsah26-Sep-07 2:52
srvsah26-Sep-07 2:52 
GeneralRe: graph include? Pin
David Crow26-Sep-07 2:57
David Crow26-Sep-07 2:57 
AnswerRe: graph include? Pin
Nishad S26-Sep-07 2:40
Nishad S26-Sep-07 2:40 
GeneralRe: graph include? Pin
srvsah26-Sep-07 2:44
srvsah26-Sep-07 2:44 
GeneralRe: graph include? Pin
Nishad S26-Sep-07 2:46
Nishad S26-Sep-07 2:46 
AnswerRe: graph include? Pin
toxcct26-Sep-07 2:41
toxcct26-Sep-07 2:41 
AnswerRe: graph include? Pin
Hamid_RT26-Sep-07 3:17
Hamid_RT26-Sep-07 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.