Valgrind reporting “brk segment overflow in thread

2019-06-18 18:55发布

This question already has an answer here:

I wonder what this message implies:

==18151== brk segment overflow in thread #1: can't grow to 0x4a26000

Note that the code runs just fine and the output is correct. Should I just ignore this message? And what does it mean?

标签: c++ valgrind
1条回答
一夜七次
2楼-- · 2019-06-18 19:24

I think you can ignore it. I got the message in a new allocation in some code that seemed to work perfectly and I also get the message it in the following code:

#include <vector>

struct Something
{
    Something() : a1(0), b1(0) { }
    unsigned short a1;
    unsigned short b1;
};

const int allocsize = 10000;

struct Tester
{
   Tester()
   {
       for (int u = 0; u < allocsize; ++u)
           data.push_back(new Something[519]);
   }

   ~Tester()
   {
       for (int u = 0; u < allocsize; ++u)
           delete[] (data[u]);
   }

   std::vector<Something*> data;
};

void test()
{
     Tester t;
     // while (true) {;}
}

int main()
{
    test();
    return 0; 
}

I also noticed that others experience the same issue:

Valgrind reporting a segment overflow

查看更多
登录 后发表回答