boostorg / boostorg/range

Memory issue when joining ranges in a for-loop

Open
#118 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
45
Forks
104
PR merge metrics
No merged PRs in 30d

Description

We are facing a memory issue (process is killed by the OOMKiller) when we join ranges inside a for loop. The idea here, is to flatten a list of ranges before returning the new range.

```
#include
#include
#include

struct A {
};

using Range = typename boost::any_range;

struct B {
std::vector v{10, A()};
};

struct C {
std::vector v{30, B()};

Range getAll() const {
Range all;
for (const auto& b : v) {
all = boost::range::join(all, b.v);
}
return all;
}
}

int main(int argc, char** argv) {
C c;
for (const A& a : c.getAll()) {
// Do something with a
}

return 0;
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.