> Hope someone can help me with this.
I'll be happy to give you a hand.
> I got this little function fetching files om mongodb, it works great,
> but It's leaking memory.
> If i hit It using apache benchmark 100000 times, the memory usage keep
> growing ( +3G )
I haven't tested your program yet, and I have a few things to do right
now, but give me a moment and I'll evaluate this locally to see what's
going on.
> btw, I'm on 64 bit linux, and weekly go, and newest mgo.
Ok.
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/blog
http://niemeyer.net/twitter
No problem, and sorry to see you're having issues.
> I've cut away all the crap, and I can reproduce the problem with this
> code, It's using about 3G ram. (using top to measure)
Ah, very nice. That'll make it pretty easy to sort out what's going on.
Thanks!
Alright, I think the issue is being caused by the use of SetFinalizer
in GridFS. I can't see why it's causing a problem yet, because as far
as I can see there are no cycles involved (there's nothing pointing to
the file), but either way as long as the file is properly closed it's
really not doing anything, so should be fine to remove it until I
understand why it's misbehaving.
Can you please try it out in your real environment? Here is the trivial patch:
http://pastebin.ubuntu.com/638650/
A last question, Is it ok to use a global var to store the seesion in,
like i do in my web app ?
regards
That's great to know. Thanks for the reproducers.
> A last question, Is it ok to use a global var to store the seesion in,
> like i do in my web app ?
I'm not a fan of that kind of global variable myself, so I wouldn't
advise you to use it. That said, it's a conceptual problem (harder to
test, etc) rather than a bug, so it will work. As a note, if you
decide to go with it, mgo is concurrency-safe so you can access the
variable without locks, assuming it has been put in place without
races..