Skip to content

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalgo2462 committed Nov 28, 2016
1 parent 2d71bb7 commit bc87029
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VoronoiLib/FortunesAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static LinkedList<VEdge> Run(List<FortuneSite> sites, double minX, double
var edges = new LinkedList<VEdge>();
var deleted = new HashSet<FortuneCircleEvent>();

//TODO: Figure out memory leak with deleted...
//init edge list
while (eventQueue.Count != 0)
{
Expand All @@ -33,6 +32,7 @@ public static LinkedList<VEdge> Run(List<FortuneSite> sites, double minX, double
}
else
{
//previously processed is being added to deleted...
beachLine.RemoveBeachSection((FortuneCircleEvent) fEvent, eventQueue, deleted, edges);
}
}
Expand Down
6 changes: 5 additions & 1 deletion VoronoiLib/Structures/BeachLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ internal void RemoveBeachSection(FortuneCircleEvent circle, MinHeap<FortuneEvent
var vertex = new VPoint(x, y);

//multiple edges could end here
var toBeRemoved = new List<RBTreeNode<BeachSection>> {section};
var toBeRemoved = new List<RBTreeNode<BeachSection>>();

//look left
var prev = section.Previous;
Expand All @@ -242,6 +242,10 @@ internal void RemoveBeachSection(FortuneCircleEvent circle, MinHeap<FortuneEvent
next = next.Next;
}

section.Data.Edge.End = vertex;
section.Next.Data.Edge.End = vertex;
section.Data.CircleEvent = null;

//odds are this double writes a few edges but this is clean...
foreach (var remove in toBeRemoved)
{
Expand Down

0 comments on commit bc87029

Please sign in to comment.