Skip to content

Commit

Permalink
Break memory cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jul 26, 2023
1 parent d5b2d12 commit 5ec5823
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ReadIterations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@ SeriesIterator::SeriesIterator(
{
auto &data = get();
data.parsePreference = std::move(parsePreference);
data.series = std::move(series_in);
/*
* Since the iterator is stored in
* internal::SeriesData::m_sharedStatefulIterator,
* we need to use a non-owning Series instance here for tie-breaking
* purposes.
* This is ok due to the usual C++ iterator invalidation workflows
* (deleting the original container invalidates the iterator).
*/
data.series = Series(std::shared_ptr<internal::SeriesData>(
series_in.m_series.get(), [](auto const *) {}));
auto &series = data.series.value();
if (series.IOHandler()->m_frontendAccess == Access::READ_LINEAR &&
series.iterations.empty())
Expand Down

0 comments on commit 5ec5823

Please sign in to comment.