Jan 24 2008
∞
Incredibly Stupid People on freenode#ruby
- kirindave: We're trying to figure out why http://pastie.caboo.se/142875 might leak so badly.
- RubyPanther: "leak?"
- kirindave: Yes.
- RubyPanther: why do you think it leaks?
- kirindave: RubyPanther: Run the code.
- RubyPanther: kirindave: it's an endless loop, I'm not going to run it ;)
- kirindave: RubyPanther: Why do you think it doesn't leak?
- RubyPanther: kirindave: leaks are to be proven, not disproven :)
- JamesKilton: kirindave: Define "leak". This code doesn't seem like a real use case
- magicwindow: joined the channel.
- kirindave: JamesKilton: This is a reduction of some code that's used in a json-rpc service app that sits over BDB. It leaks memory horrendously.
- kirindave: JamesKilton: We've removed the socket listens and whatnot and reduced it down to this, which reproduces the leak.
- kirindave: RubyPanther: Then run the fucking code?
- RubyPanther: kirindave: the most common reason for "leaking" is, it's not really leaking, there is a loop, and, I know this doesn't sound right, but please trust enough to try it... you have to paste the inside of the loop into a method, and just call the method from inside the loop, without doing any work inside the loop that isn't in a method
- RubyPanther: because of closures, and scope
- RubyPanther: I had a loop with Hpricot once that was eating over 1G of RAM, I thought it was a leak, but _why told me this sollution, and to my surprise, the memory usage reduced to 50M
- JamesKilton: kirindave: "should" is a dangerous word
- kirindave: JamesKilton: I was under the impression that ruby was a garbage collected language.
- JamesKilton: that implies you know exactly how the GC works. Obviously the resulting arrays and strings of that method are still "in-use"
- RubyPanther: if closures are laying around, it shouldn't ever be able to free it, until you return from the method and let them drop out of use..;
- JamesKilton: By what we don't know
- kirindave: JamesKilton: But that's the whole program.
- RubyPanther: even if it doesn't "look like" they are still being used
- kirindave: If they _are_ being retained by the loop context, that's a bug.
- RubyPanther: lol
- kirindave: There is no reasonable justification for this code to leak memory.
- RubyPanther: tsk tsk
- JamesKilton: sighs
- RubyPanther: it's not a leak
- sepp2k: RubyPanther: I'd be very surprised if loop would store the closure.
- RubyPanther: it you misusing the memory
- JamesKilton: sepp2k: It's you refusing to accept that a language may work slightly differently than you expect it to
- kirindave: RubyPanther: I'm confused how you could classify this as anything but a memory leak.
- sepp2k: JamesKilton: Me? What'd I do?
- RubyPanther: sepp2k: I was very surprised when pasting the inside of the loop into a method with no other changes reduced the memory consumption by over 900M, but luckily I was A) smart enough to ask _why and B) smart enough to listen to him
- JamesKilton: sepp2k: I know it's not your code, but you're fighting like it is
- sepp2k: JamesKilton: I'm not fighting at all. This is the first thing I said in this discussion.
- RubyPanther: well, not literally
- sepp2k: No, second. First was the thing about the GC
- kirindave: This entire discussion is blowing my mind. This is a memory leak. If the GC isn't collecting these then it is not doing its job.
- RubyPanther: kirindave: if you believe it is a memory leak, you will probably have difficulty solving it
- kirindave: RubyPanther: It was a mistake to come into #ruby
- kirindave: RubyPanther: People like you render it useless.
- RubyPanther: of the 100 people with "memory leaks" in Ruby proggies that I've seen, there was like 1 who had a leak
- JamesKilton: kirindave: Wow.
- JamesKilton: just wow
- RubyPanther: the ones who insisted it was a leak, spent a long unhappy time getting the memory usage down
- kirindave: RubyPanther: Please identify the leak in that code then.
- JamesKilton: kirindave: It's you refusing to accept that a language may work slightly differently than you expect it to
- RubyPanther: it might use a surprising amount of memory
- RubyPanther: it probably uses more than is needed
- kirindave: JamesKilton: So why would it leak? Where is that code retaining memory?
- JamesKilton: besides, memory leaks by definition don't happen in Ruby
- JamesKilton: RubyPanther already answered that kirin!
- JamesKilton: it seems to have to do with closures and how they operate with the GC
- kirindave: He answered with TomCrusian nonsense.
- JamesKilton: what?!
- JamesKilton: what the hell does that even mean?
- RubyPanther: he's calling me a scientologist
- kirindave: Look, every loop in ruby is done via a closure.
- LegendaryPenguin: anyone?
- kirindave: RubyPanther: No, I'm calling you stupid *like* a scientologist.
- JamesKilton: you're pathetic kirindave. You come asking why, and then insult people who try to help.
- narcoclepsy: ziiiiing!
- kirindave: JamesKilton: I'm insulting people who aren;t helping, but arguing the language _should_ behave this way.
- sepp2k: JamesKilton: This isn't about closures. He said it works fine, when starting the GC right away.
- kirindave: sepp2k: Thank you for listening at least. :)