February 28, 2004 Re: Bug in heap allocations for strings -- garbage collection problem? - bug report for digital mars--2004-02-20.rtf [01/11] | ||||
---|---|---|---|---|
| ||||
In article <c1947u$i94$1@digitaldaemon.com>, Richard Haney says... > >My application crashes apparently while the following declaration code is trying to allocate memory on the heap: > >const string lt("<"); > .. > >But the first sign of memory allocation problems is earlier in the program when the following statement has allocated the string "Comments on wild0" when it should have allocated the string "Comments on wilderness preservation": > >subj_p = new string(outbuf.begin(),out_scan); > I was able to get rid of the memory allocation problem by avoiding the use of the 'new' operator. Evidently string objects will do their own dynamic allocation of whatever space they need. I suppose the problem might have been due to a need to turn on the compiler option "allow overloading of new[], delete[] operators", but it did not seem clearly needed and I have not successfully tried toggling this switch to get rid of the problem. |
Copyright © 1999-2021 by the D Language Foundation