Effect of merging allocations on memory leakage
Section [expr.new]
United Kingdom

Created on 2013-09-28.00:00:00 last changed 81 months ago


Date: 2013-09-15.00:00:00

Notes from the September, 2013 meeting:

EWG was not so concerned with memory leaks, but there are problems with the current wording dealing with lifetime issues. In particular, the existing wording did not guarantee that all of the merged allocations would, in fact, be executed. The intended direction is to relax the strict lifetime containment requirement from the current wording but to ensure that all of the allocations and frees will be executed, which requires that the allocation and initialization of later objects be non-throwing.

Date: 2014-03-03.00:00:00
N3690 comment GB 4

[Applied to WP at the February, 2014 meeting as part of document N3914.]

The strategy of merging allocations could turn a small memory leak into a big one. For example,

  class P { 
    int x; 
  class Q { 
    Q(){ throw 42; } 
    int x[LARGE_NUMBER]; 

    P* p1 = new P(); 
    Q* q1 = new Q(); // bang :-( 
    // don't get here 
    delete q1; 
    delete p1; 

Instead of just leaking the first allocation, this could result in leaking the combined allocation.

Date User Action Args
2014-11-24 00:00:00adminsetstatus: dr -> c++14
2014-03-03 00:00:00adminsetstatus: drafting -> dr
2013-10-14 00:00:00adminsetmessages: + msg4623
2013-09-28 00:00:00admincreate