From 0b05964faa99304bf69aee8d471a05d82c0e8b92 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Sun, 15 Feb 2015 23:57:54 +0300 Subject: [PATCH] Add ability to Flush CollectionFactory. #116 --- deb/collections.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/deb/collections.go b/deb/collections.go index fb6a5592..a34363b4 100644 --- a/deb/collections.go +++ b/deb/collections.go @@ -80,3 +80,15 @@ func (factory *CollectionFactory) PublishedRepoCollection() *PublishedRepoCollec return factory.publishedRepos } + +// Flush removes all references to collections, so that memory could be reclaimed +func (factory *CollectionFactory) Flush() { + factory.Lock() + defer factory.Unlock() + + factory.localRepos = nil + factory.snapshots = nil + factory.remoteRepos = nil + factory.publishedRepos = nil + factory.packages = nil +}