Line | |
---|
1 | #include "muscle.h" |
---|
2 | #include <stdio.h> |
---|
3 | #include <new> |
---|
4 | |
---|
5 | const int ONE_MB = 1024*1024; |
---|
6 | const size_t RESERVE_BYTES = 8*ONE_MB; |
---|
7 | static void *EmergencyReserve = 0; |
---|
8 | |
---|
9 | void OnOutOfMemory() |
---|
10 | { |
---|
11 | free(EmergencyReserve); |
---|
12 | fprintf(stderr, "\n*** OUT OF MEMORY ***\n"); |
---|
13 | fprintf(stderr, "Memory allocated so far %g MB\n", GetMemUseMB()); |
---|
14 | extern MSA *ptrBestMSA; |
---|
15 | if (ptrBestMSA == 0) |
---|
16 | fprintf(stderr, "No alignment generated\n"); |
---|
17 | else |
---|
18 | SaveCurrentAlignment(); |
---|
19 | exit(EXIT_FatalError); |
---|
20 | } |
---|
21 | |
---|
22 | void SetNewHandler() |
---|
23 | { |
---|
24 | EmergencyReserve = malloc(RESERVE_BYTES); |
---|
25 | std::set_new_handler(OnOutOfMemory); |
---|
26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.