Skip to content

Commit

Permalink
Merged in debio/redeem/develop (pull request intelligent-agent#111)
Browse files Browse the repository at this point in the history
Don't Hold on to Step Buffers After a Path is Complete

Paths in the path planner live in a circular buffer and store all
their steps in vectors. When we're done with a path, we zero it
and eventually it gets filled again. Originally, we were clearing
the vectors of steps with std::vector.clear(), which clear out all
the old steps but holds on to underlying buffer. Normally this is
an optimization, but it also means that every axis of every path
in the path queue (which is a few thousand elements long) will
always hold on to the largest buffer it's had to use so far.

This isn't a "leak" per se because we know where all that memory is
and no pointers have been "lost," but this does cause Redeem memory
usage to rise until it exceeds the maximum of the BBB, particularly
on prints with very long moves with many steps. To fix this, swap
the step vectors with empty vectors to force std::vector to free
these underlying buffers and re-allocate whenever a Path is used.
  • Loading branch information
ThatWileyGuy committed May 15, 2017
1 parent 0f55689 commit 145b34e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion redeem/path_planner/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ void Path::zero() {

for (auto& stepVector : steps)
{
stepVector.clear();
std::vector<Step> empty;
stepVector.swap(empty);
}
}

Expand Down

0 comments on commit 145b34e

Please sign in to comment.