0

In case a user sent the SIGINT interrupt ( or any other interrupt that would interrupt program execution ) to a program, why does the std::vector deallocator fail to run automatically in such a case?

i used this test code to try it out:

#include <cstdio>
#include <vector>

using std::vector;

int main(void) {
  vector<int> buf(40, 0);

  int i{};
  for (;;) {
    printf("!my great program: %d\n", buf[i]);
    ++i;
  }

  return 0; // a pipe dream
}

i compiled it with debug symbols using gcc and ran it through valgrind using this command: valgrind --leak-check=full --show-leak-kinds=all -v --log-file=val.log ./prog

after running the program through valgrind i got this as the heap summary:

...
==602714== HEAP SUMMARY:
==602714==     in use at exit: 73,888 bytes in 3 blocks
==602714==   total heap usage: 3 allocs, 0 frees, 73,888 bytes allocated
...
winterr_dog
  • 49
  • 1
  • 6

0 Answers0