15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Debug memory allocator is broken...

michael berganovsky -- michael_berganovsky@ibi.com
Wednesday, September 25, 1996

     Environment : VC++ 4.2a on WinNT 4.0.

     We noticed memory leak which is reported by MSVC run-time when
     exception happens in constructor when we are using MFC. Investigation
     shows that you can get memory leak every time you are overloading
     global new with the placement version and are using this placement in
     your code. The reason is that Microsoft compiler supports only half of
     ANSI draft - you can overload global new the way you want but you can
     not create matching delete to take care of allocated memory.

     --- This is from the working draft:

     18 If the constructor throws an exception and the new-expression
     contains a new-placement, a name lookup is performed on the name of
     operator delete in the scope of this new-expression. If the lookup
     succeeds and exactly one of the declarations found matches the
     declaration of that placement operator new, then the matching
     placement  operator delete shall be called.

     19 A declaration of placement operator delete matches the declaration
     of a placement operator new when it has the same number of parameters
     and all  parameter  types except the first are identical disregarding
     top-level cv-qualifiers.

     --- end of the quote

     To the best of our knowledge there is no way to declare matching
     delete in 4.2a version of the compiler, which IMHO leads to the
     possible memory leaks each time you are using placement version of the
     new operator. And you have this situation guaranteed if you are using
     MFC in DEBUG mode and allow DEBUG_NEW to be performed in your code!


     Best wishes...




Mike Blaszczak -- mikeblas@nwlink.com
Friday, September 27, 1996

At 10:12 9/25/96 edt, you wrote:
>     Environment : VC++ 4.2a on WinNT 4.0.

>     We noticed memory leak which is reported by MSVC run-time when
>     exception happens in constructor when we are using MFC.

Yep.

This issue has been discussed on the list at great length at least
twice before.  Please see http://www.nwlink.com/~mikeblas/PlacementNewBug.txt
for a write up of exactly what's going on.

>     To the best of our knowledge there is no way to declare matching
>     delete in 4.2a version of the compiler,

There is no 4.2a version of the compiler.

.B ekiM
http://www.nwlink.com/~mikeblas/
Don't look at my hands: look at my _shoulders_!
These words are my own. I do not speak on behalf of Microsoft.




michael berganovsky -- michael_berganovsky@ibi.com
Monday, September 30, 1996


     I was not subscribed to this list long enough to notice the discussion
     - sorry for any duplication. I simply wanted to warn people about the
     problem we encountered. I don't need to read the text Mike is pointing
     me at because I know exactly what is going on. However, I think that
     in his description of the problem Mike is missing a couple of key
     points - this issue ( a bug or problem ) is NOT MFC related. It just
     happens to show itself clearly in debug version of MFC.

     Workarounds suggested are no good - I can create this leak in release
     mode without using MFC at all. And I am not using CFile!

     Second - this IS not a problem with compiler omitting cleanup code.
     For what I can see this is a problem with the compiler not allowing to
     overload delete the way it suppose by the standard. And as such THIS
     IS A VERY SERIOUS PROBLEM FOR ANY COMPILER WHICH CLAIMS TO BE ANSI
     COMPLIANT.

     -- Best Wishes

______________________________ Reply Separator _________________________________
Subject: Re: Debug memory allocator is broken...
Author:  mfc-l@netcom.com at tcpgate
Date:    9/29/96 8:54 PM


At 10:12 9/25/96 edt, you wrote:
>     Environment : VC++ 4.2a on WinNT 4.0.

>     We noticed memory leak which is reported by MSVC run-time when
>     exception happens in constructor when we are using MFC.

Yep.

This issue has been discussed on the list at great length at least
twice before.  Please see http://www.nwlink.com/~mikeblas/PlacementNewBug.txt
for a write up of exactly what's going on.

>     To the best of our knowledge there is no way to declare matching
>     delete in 4.2a version of the compiler,

There is no 4.2a version of the compiler.

.B ekiM
http://www.nwlink.com/~mikeblas/
Don't look at my hands: look at my _shoulders_!
These words are my own. I do not speak on behalf of Microsoft.






| Вернуться в корень Архива |