Re: Problem with memory allocation

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I've never seen this problem, but since you mention that you have multiple threads maybe more than one thread is trying to update the data at the same time. Or, perhaps you're running into a reference counting problem and you really are running out of memory from simply allocating the string (fresh) over and over.

Tom

"Punit Kaur" <Punit Kaur@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:0D8E7195-9798-471C-831E-F8F383847DBD@xxxxxxxxxxxxxxxx
Hi,

I have a multi-threaded application where in one of the functions that is
called inside one of the threads, I have declared a CString variable called
ErrorText. I leave the application to run overnight in the Debug mode.
Somehow, the application runs successfully for a few hours and then freezes
at a random time and displays a message box " User Breakpoint called from
code at 0x10212ad0". I see this message when I come back in the morning. It
stops at one of the statements in dbgheap.c... then I step through the code
and it goes through many functions of which one of them is a CString function
AllocBuffer. After stepping through all the code in the library, it returns
to the function where the following line was called:

ErrorText = "Some String";

I believe this assignment statement is causing some memory allocation
problems. I am also not sure if there are any memory leaks in my application.
I remember another problem in the past, where this string was overwriting
another string. To solve that problem, I just had to initialize that
variable's memory using memset and it started working fine...

Has someone seen such problems before? If yes, please suggest what I should
do. I would also like to understand the memory allocation stuff... I shall
post the function if anybody wants to have a look at it.

.



Relevant Pages

  • Re: Doubts on Defining and declaring variables
    ... 1.Dim iage ... and allocate memory for each of them ... My understanding:-Still No memory allocation done at this ... Now since string is assigned to iage,So will ...
    (microsoft.public.scripting.vbscript)
  • Re: Problem with memory allocation
    ... I changed the variable to char array and instead of assignment stmt, ... I believe this assignment statement is causing some memory allocation ... I remember another problem in the past, where this string was overwriting ... I would also like to understand the memory allocation stuff... ...
    (microsoft.public.vc.mfc)
  • Re: Problem with memory allocation
    ... I changed the variable to char array and instead of assignment stmt, ... I believe this assignment statement is causing some memory allocation ... I remember another problem in the past, where this string was overwriting ... I would also like to understand the memory allocation stuff... ...
    (microsoft.public.vc.mfc)
  • Re: Difference between String variable and String Class definition
    ... String class definition. ... as each other about memory allocation or not? ... The first line allocates memory for the literal "java". ...
    (comp.lang.java.programmer)
  • Re: Fast string operations
    ... Looping: I thought looping over arrays in managed code was "slow" ... array handling and such. ... The problem with TrimHelper is that it always returns a new string instance. ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)