My program was "Killed"

Perhaps the core, as suggested in this question . I would like to know why they killed me, something like a kill function. :)

Also, is there anything I can do to make my program run normally?


Hr

My program runs correctly. However, we were faced with a large data set: 1.000.000 x 960 floats, and my laptop at home could not take it (gave std::bad_alloc()).

Now I'm in the lab, on a desktop with 9.8 GB on a 3.00 GHz × 4 processor, which has more than twice as much memory as a laptop at home.

At home, the data set cannot be loaded into std::vectorwhere the data is stored. Here, in the laboratory, this was carried out, and the program continued with the construction of the data structure.

This was the last time I heard from him:

Start building...
Killed

The lab desktop runs on Debian 8. My program runs as expected for a subset of the data set, in particular 1.00.000 x 960 float.


EDIT

strace The conclusion is finally available:

...
brk..
brk(0x352435000)                        = 0x352414000
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f09c1563000
munmap(0x7f09c1563000, 44683264)        = 0
munmap(0x7f09c8000000, 22425600)        = 0
mprotect(0x7f09c4000000, 135168, PROT_READ|PROT_WRITE) = 0
...
mprotect(0x7f09c6360000, 8003584, PROT_READ|PROT_WRITE) = 0
+++ killed by SIGKILL +++

So, this suggests that I lost my memory. I think so.

+4
source share
2 answers

In C ++, a float is a single (32-bit) floating point number: http://en.wikipedia.org/wiki/Single-precision_floating-point_format

, ( ) 3 840 000 000 .

3,57627869 .

, , .

, Linux , , , :

https://unix.stackexchange.com/questions/136291/will-linux-start-killing-my-processes-without-asking-me-if-memory-gets-short

, overcommit, .

, , .. 32- ? 2 ^ 32 (4 ), , 32- .

, , ... bum bum bum

+3

,

static bool installSignalHandler(int sigNumber, void (*handler)(int) = signal_handler)
{
    struct sigaction action;
    memset(&action, 0, sizeof(action));
    action.sa_flags = SA_SIGINFO;
    action.sa_sigaction = signal_handler_action;
    return !sigaction(sigNumber, &action, NULL);
}

:

installSignalHandler(SIGINT);
installSignalHandler(SIGTERM);

:

static void signal_handler_action(int sig, siginfo_t *siginfo, void* content) 
{
    switch(sig) {
        case SIGHUP:
            break;
        case SIGUSR1:
            break;
        case SIGTERM:
            break;
        case SIGINT:
            break;
        case SIGPIPE:
            return;
    }
}

siginfo_t ,

printf("Continue. Signo: %d - code: %d - value: %d - errno: %d - pid: %ld - uid: %ld - addr %p - status %d - band %d",
                      siginfo->si_signo, siginfo->si_code, siginfo->si_value, siginfo->si_errno, siginfo->si_pid, siginfo->si_uid, siginfo->si_addr,
                      siginfo->si_status, siginfo->si_band);
0

All Articles