Weston Pace created ARROW-14376:
-----------------------------------

             Summary: [C++] Split PushGenerator producer into separately 
tracked entity 
                 Key: ARROW-14376
                 URL: https://issues.apache.org/jira/browse/ARROW-14376
             Project: Apache Arrow
          Issue Type: Improvement
          Components: C++
            Reporter: Weston Pace
            Assignee: Weston Pace


The PushGenerator keeps a strong reference to its producer, keeping it alive 
until the generator closes.  This means the producer will never auto-close if 
all references to it are lost.  This can lead to memory leaks like:

{code:cpp}
TEST(Weston, MemTest) {
  PushGenerator<util::optional<int>> int_prod;
  AsyncGenerator<util::optional<int>> int_gen = int_prod;
  Future<> visit_fut = VisitAsyncGenerator(std::move(int_gen), [] 
(util::optional<int>) {
    return Status::OK();
  });
}
{code}

If we split the push generator creation code so it creates both a producer and 
a generator as separate objects then the lifecycle for the producer can be 
tracked separately and, if all references are lost, it can abort the iteration.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to