Click here to Skip to main content
15,915,713 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Parser for C++ Pin
Member 14276929-Jun-05 5:33
Member 14276929-Jun-05 5:33 
GeneralRe: Parser for C++ Pin
Trollslayer9-Jun-05 7:33
mentorTrollslayer9-Jun-05 7:33 
GeneralRe: Parser for C++ Pin
Member 14276929-Jun-05 1:22
Member 14276929-Jun-05 1:22 
Generalproblems in dynamic Memory allocation Pin
Amit Mulay9-Jun-05 0:32
Amit Mulay9-Jun-05 0:32 
GeneralRe: problems in dynamic Memory allocation Pin
James R. Twine9-Jun-05 1:07
James R. Twine9-Jun-05 1:07 
GeneralRe: problems in dynamic Memory allocation Pin
Amit Mulay9-Jun-05 1:47
Amit Mulay9-Jun-05 1:47 
GeneralRe: problems in dynamic Memory allocation Pin
Amit Mulay9-Jun-05 1:58
Amit Mulay9-Jun-05 1:58 
GeneralRe: problems in dynamic Memory allocation Pin
James R. Twine9-Jun-05 4:38
James R. Twine9-Jun-05 4:38 
Amit Mulay wrote:
May I ask u, What were the problems u were getting when u were using TerminateThread( ),

   When your thread is allocated, it gets its stack space.  In Win32, this defaults to 1MB, but can be changed.  Since threads operate in your process' address space, the memory (address) for the thread's stack exists in your process space.

   When a thread exits normally (it returns from its ThreadProc), the memory area reserved for its stack gets returned back to your process.  But if you kill the thread, it never gets cleaned up correctly, and that reserved address space remains unavailable.

   Over time, this can consume your process' address space and will cause new threads to fail creation, or memory allocation to fail because even though free memory does exist, your process' memory area has no more available addresses (range) to map that memory in or to reserve for the thread's stack. 

   Think of it like being in a candy store, with plenty of money.  You start buying candy and filling your pockets.  You then eat the candy, but you put the empty candy wrappers back into your pocket.  After a while, your pockets will be full of empty wrappers, and you cannot hold any more candy, even though more candy is available and you still have money to buy it.  You just do not have the "space" for anymore because you did not "clean up" the wrappers, you kept them.

Amit Mulay wrote:
Does that AfxEndThread( )also creates same problem that were created by TerminateThread( )?

   No, because it does not cause the thread to exit in the same way.  Since this function is called from within the thread, the thread "knows" it is ending and cleans itself up (via endthreadex(...)).

   Peace!

-=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites
(Please rate this post!)
GeneralRe: problems in dynamic Memory allocation Pin
Amit Mulay9-Jun-05 2:12
Amit Mulay9-Jun-05 2:12 
GeneralRe: problems in dynamic Memory allocation Pin
James R. Twine9-Jun-05 4:25
James R. Twine9-Jun-05 4:25 
GeneralRe: problems in dynamic Memory allocation Pin
Tim Smith9-Jun-05 3:50
Tim Smith9-Jun-05 3:50 
GeneralRe: problems in dynamic Memory allocation Pin
James R. Twine9-Jun-05 4:26
James R. Twine9-Jun-05 4:26 
GeneralRe: problems in dynamic Memory allocation Pin
Alexander M.,9-Jun-05 5:46
Alexander M.,9-Jun-05 5:46 
GeneralRe: problems in dynamic Memory allocation Pin
James R. Twine9-Jun-05 5:56
James R. Twine9-Jun-05 5:56 
Generalstd::map problem Pin
Bob Stanneveld8-Jun-05 23:34
Bob Stanneveld8-Jun-05 23:34 
GeneralDoh! Pin
Bob Stanneveld9-Jun-05 0:20
Bob Stanneveld9-Jun-05 0:20 
GeneralRe: std::map problem Pin
Nilesh K.9-Jun-05 0:21
Nilesh K.9-Jun-05 0:21 
GeneralRe: std::map problem Pin
Bob Stanneveld9-Jun-05 0:26
Bob Stanneveld9-Jun-05 0:26 
GeneralRe: std::map problem Pin
grasstafari9-Jun-05 0:25
grasstafari9-Jun-05 0:25 
GeneralPOST string to .asp Pin
dex_ter118-Jun-05 23:24
dex_ter118-Jun-05 23:24 
GeneralRe: POST string to .asp Pin
Bob Stanneveld8-Jun-05 23:54
Bob Stanneveld8-Jun-05 23:54 
GeneralRe: POST string to .asp Pin
ThatsAlok9-Jun-05 1:05
ThatsAlok9-Jun-05 1:05 
GeneralRe: POST string to .asp Pin
dex_ter119-Jun-05 15:16
dex_ter119-Jun-05 15:16 
GeneralRe: POST string to .asp Pin
ThatsAlok9-Jun-05 18:21
ThatsAlok9-Jun-05 18:21 
GeneralLNK2001 Error Using Edit Control Variable in static function Pin
CNewbie8-Jun-05 23:03
CNewbie8-Jun-05 23:03 

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.