View Single Post
  #1 (permalink)  
Old May 15th, 2017, 11:55 AM
echristopherson echristopherson is offline
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: May 2017
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Can't make 09_ConstructorError release already-allocated memory

I've been fiddling with the 09_ConstructorError example, changing the line

Matrix m(10, 10);
to use different widths and heights. What I've found is that I can't seem to make it act as it's supposed to, i.e. to allocate memory until allocation finally fails, and then delete[] all the previously-allocated 1-dimensional arrays and then exits with a bad_alloc exception. Instead, if I use small to moderate values for the matrix bounds, it just allocates successfully and exits normally; but if I set really high bounds, it exits with a SIGKILL, apparently without releasing any of the already-allocated arrays (I can tell because I've put some debug statements in the deallocation part).

I've tried this on Mac OS X and Linux, but not Windows. What am I doing wrong?

Last edited by echristopherson; May 15th, 2017 at 12:00 PM.. Reason: code tags
Reply With Quote