Overriding global operator new to track huge memory allocations?
<p>I am trying to produce a special build of a large monolithic application. The problem I am trying to solve is tracking hard-to-reproduce huge memory allocations (30-80 gigabytes, judging by what OS reports).
I believe the problem is an std::vector resized to a negative 32-bit integer value. The only platform exhibiting this behavior is Solaris (maybe it's the only platform that manages to successfully allocate such chunks of contiguous memory).
Can I globally replace std::vector with my class, delegating all calls to the real vector, watching for suspicious allocations <code>(size &gt; 0x7FFFFFFFu)</code>? Maybe selectively replace the constructor that takes <code>size_t</code> and the <code>resize()</code> methods? Maybe even hijacking the global operator new?</p>
