title: fatal error out of memory
body: <p>So I wrote a daemon in go that handles around 800k documents and i'm having an out of memory problem.</p>
  
  <p>From what i saw when getting the documents from mongodb the memory usage increases with every loop.</p>
  
  <pre><code>func main() {
  session, err := mgo.Dial("localhost")
  if err != nil { panic(err) }
  defer session.Close()
  
  subscriptionsC  = session.DB("sm").C("subscriptions")
  subscriptions   := []Subscription{}
  
  for {
      subscriptions = GetSubscriptions()
  </code></pre>
  
  <p>And the other function is:</p>
  
  <pre><code>func GetSubscriptions()([]Subscription) {
      result  := []Subscription{}
      err    := subscriptionsC.Find(nil).Prefetch(0.0).All(&amp;result)
  
      if err != nil { Log("signups_err", err.Error() + "\n") }
      return result
  }
  </code></pre>
  
  <p>I don't know if it's redeclaring the array with each loop or what exactly happens.</p>
  
  <p>Any help would be greatly appreciated.</p>