Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Memory issue when joining ranges in a for-loop

Open
#118 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
tooling

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/range

All issues in boostorg/range

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.