Memory issue when joining ranges in a for-loop
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the supplied reproducer and read boost/range/join.hpp to trace how repeated joins retain their inputs. Confirm the behavior by iterating the range in the example; done means the same flattening use case completes without the process being killed by the OOMKiller.
Written by the indexing model from the issue text.
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 <vector>
#include <boost/range/any_range.hpp>
#include <boost/range/join.hpp>
struct A {
};
using Range = typename boost::any_range<A, boost::forward_traversal_tag, A&, std::ptrdiff_t>;
struct B {
std::vector<A> v{10, A()};
};
struct C {
std::vector<B> 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;
}
- Dominant language
- C++
- Stars
- 45
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/range
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
-
Bad is_sorted docsOpen
Difficulty 1/5 Under an hour Newbie friendliness 55/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
plengauer/DXGIOutputDuplication#81 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sudoevolve/EUI-NEO#80 ·
-
upstream update
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
conan-io/conan-center-index#31098 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day