On Fri, 23 Jan 2015 11:26:06 -0800, Charles Mills <charl...@mcn.org> wrote:

>In my test it is one 6.3MB new that fails. So I presumably have lots of spare 
>heap; just not 6.3MB. If the failure were due to a loop that did lots of tiny 
>new's then that would not be the case. If the loop involved recursion I might 
>be out of stack.
>
>One of the major chores my terminate routine does is lots and lots of 
>delete's, so that would presumably free up heap.
>
...
On Fri, 23 Jan 2015 13:11:37 -0600, Carl Kugler <carl.kug...@infoprint.com> 
wrote:

>It seems to me that you have to be careful not to do too much in your new 
>handler, because, depending on the size of the new() that failed, you might 
>have very little HEAP or STACK space to work with. One way around that might 
>be to new() a reserve buffer before calling set_new_handler() and then freeing 
>that reserve buffer in your new handler.

Actually, thinking about it some more, I shouldn't have said "depending on the 
size of the new() that failed." It would depend on the history of the heap and 
stack and their sizes, so it's really a matter of luck whether there's enough 
space left for your cleanup processing when new() fails, unless your cleanup 
processing doesn't need any space, or you reserve some. 

You can trace heap allocations with the LE MEMCHECK VHM memory leak analysis 
tool 
(https://www-304.ibm.com/support/knowledgecenter/SSB27U_5.4.0/com.ibm.zos.r9.ceea100/memcheck.htm%23memcheck?lang=en-us),
 
so you might be able to use that to determine how much heap your cleanup 
processing needs. Then there's stack...

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to