p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional C++, 3rd Edition (http://p2p.wrox.com/forumdisplay.php?f=790)
-   -   Can't make 09_ConstructorError release already-allocated memory (http://p2p.wrox.com/showthread.php?t=99516)

echristopherson May 15th, 2017 11:55 AM

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?

All times are GMT -4. The time now is 09:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.