You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During setup, allocate a buffer using the "nothrow" version of new:
pBuf = new (std::nothrow) uint8_t[1024];
During teardown, delete[] that buffer:
delete[] pBuf;
Your test body can be empty, and the setup/teardown functions can contain only those lines. This eliminates any possibility of memory leak/corruption other than in the framework.
You'll get a "Deallocating non-allocated memory" error when the test runs, because the memory leak detector didn't see the allocation by the specialized (std::nothrow) form. If you remove (std::nothrow) from the example, it will work. I have not tested this for single objects, but suspect that it exists there as well.
The text was updated successfully, but these errors were encountered:
I just noticed some lines in the output of my ./configure run relating the to (non-)throwing versions of new and delete, so it is entirely possible that this is an artifact of what ./configure discovered in my toolchain. If so, this probably isn't a bug so much as a confusing situation that might be usefully addressed in a FAQ or Troubleshooting page.
During setup, allocate a buffer using the "nothrow" version of new:
pBuf = new (std::nothrow) uint8_t[1024];
During teardown, delete[] that buffer:
delete[] pBuf;
Your test body can be empty, and the setup/teardown functions can contain only those lines. This eliminates any possibility of memory leak/corruption other than in the framework.
You'll get a "Deallocating non-allocated memory" error when the test runs, because the memory leak detector didn't see the allocation by the specialized (std::nothrow) form. If you remove (std::nothrow) from the example, it will work. I have not tested this for single objects, but suspect that it exists there as well.
The text was updated successfully, but these errors were encountered: