Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to find out *if* there is a memory leak?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Felix E. Klee  
View profile  
 More options Nov 18 2012, 5:22 am
From: "Felix E. Klee" <felix.k...@inka.de>
Date: Sun, 18 Nov 2012 11:21:47 +0100
Local: Sun, Nov 18 2012 5:21 am
Subject: How to find out *if* there is a memory leak?
How do I find out if (not where) there is a memory leak in an app?

Background: I am using Socket.IO for client/server communication, and I
want to make sure that server side resources are properly cleaned up
when a connection is closed (`disconnect` event). Memory usage should be
proportional (plus a constant) to the number of connections. It should
not increase when reloading the app in the browser.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix E. Klee  
View profile  
 More options Nov 19 2012, 9:53 am
From: "Felix E. Klee" <felix.k...@inka.de>
Date: Mon, 19 Nov 2012 15:52:40 +0100
Local: Mon, Nov 19 2012 9:52 am
Subject: Re: How to find out *if* there is a memory leak?
Just found a promising article (didn't read it yet), just some days old:

<https://hacks.mozilla.org/2012/11/tracking-down-memory-leaks-in-node-...>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Noordhuis  
View profile  
 More options Nov 19 2012, 10:41 am
From: Ben Noordhuis <i...@bnoordhuis.nl>
Date: Mon, 19 Nov 2012 16:41:02 +0100
Local: Mon, Nov 19 2012 10:41 am
Subject: Re: [nodejs] How to find out *if* there is a memory leak?
On Sun, Nov 18, 2012 at 11:21 AM, Felix E. Klee <felix.k...@inka.de> wrote:

> How do I find out if (not where) there is a memory leak in an app?

> Background: I am using Socket.IO for client/server communication, and I
> want to make sure that server side resources are properly cleaned up
> when a connection is closed (`disconnect` event). Memory usage should be
> proportional (plus a constant) to the number of connections. It should
> not increase when reloading the app in the browser.

A quick and fairly reliable approach is to start node with --expose-gc
and call gc() every few seconds, like so:

  $ cat test.js
  if (typeof gc === 'function') setInterval(gc, 5000);
  require('./main.js'); // your main application

  $ node --expose-gc test.js

Keep an eye on RSS.  If your application is at equilibrium but RSS
keeps growing indefinitely, chances are good there is a memory leak.

The reason that you need to call gc() is that the garbage collector is
lazy.  It won't collect garbage until it's forced by sheer memory
pressure - and even then it may opt to grow the heap, not sweep it.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix E. Klee  
View profile  
 More options Nov 19 2012, 6:43 pm
From: "Felix E. Klee" <felix.k...@inka.de>
Date: Tue, 20 Nov 2012 00:42:34 +0100
Local: Mon, Nov 19 2012 6:42 pm
Subject: Re: [nodejs] How to find out *if* there is a memory leak?
On Mon, Nov 19, 2012 at 4:41 PM, Ben Noordhuis <i...@bnoordhuis.nl>
wrote:

> A quick and fairly reliable approach is to start node with --expose-gc
> and call gc() every few seconds

I like this approach, simple and light weight! Only probably it is not
enough to be on the safe side:

At least on WinXP, I see quite some fluctuations of the "Private Bytes"
as reported by Process Explorer for `node.exe`. Of course, I can see the
memory usage go up when there are more connections, and it fortunately
goes down when connections are closed. However, due to the fluctuations
it is hard to tell if some bytes are leaking on every closed connection.

Perhaps, I'll try on Linux later.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stefan Zehe  
View profile  
 More options Nov 20 2012, 3:03 am
From: Stefan Zehe <s.z...@upjers.com>
Date: Tue, 20 Nov 2012 09:02:32 +0100
Local: Tues, Nov 20 2012 3:02 am
Subject: Re: [nodejs] How to find out *if* there is a memory leak?
Am 19.11.2012 16:41, schrieb Ben Noordhuis:
> Keep an eye on RSS. If your application is at equilibrium but RSS
> keeps growing indefinitely, chances are good there is a memory leak.

Is js-code responsible for RSS memory leaks or only for the heap-growing
ones?
if both are js-code-caused, can someone give a code-example on how to
leaks rss and heap?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix E. Klee  
View profile  
 More options Nov 25 2012, 10:28 am
From: "Felix E. Klee" <felix.k...@inka.de>
Date: Sun, 25 Nov 2012 16:28:04 +0100
Local: Sun, Nov 25 2012 10:28 am
Subject: Re: [nodejs] How to find out *if* there is a memory leak?
On Mon, Nov 19, 2012 at 4:41 PM, Ben Noordhuis <i...@bnoordhuis.nl>
wrote:

> A quick and fairly reliable approach is to start node with --expose-gc
> and call gc() every few seconds, like so:

> [...]

With [memwatch][1] something similar can be done:

    $ cat test.js
    'use strict';

    var memwatch = require('memwatch');

    memwatch.on('stats', function (stats) {
        console.log('current base:', stats.current_base);
    });

    setInterval(memwatch.gc, 5000);

    $ node --expose-gc test.js
    current base: 1217308
    current base: 1217512
    current base: 1371772
    current base: 1373436

Again I do see fluctuations; haven't investigated that yet.

[1]: https://github.com/lloyd/node-memwatch


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joel Rolfe  
View profile  
 More options Nov 27 2012, 3:26 pm
From: Joel Rolfe <jro...@gmail.com>
Date: Tue, 27 Nov 2012 12:26:02 -0800 (PST)
Local: Tues, Nov 27 2012 3:26 pm
Subject: Re: How to find out *if* there is a memory leak?

I just put the following together on monitoring memory, and finding memory
leaks.  Very memwatch centered.  Hope it helps:

http://code.osnap.us/wp/?p=43


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
themitchy  
View profile  
 More options Nov 28 2012, 12:16 pm
From: themitchy <mi...@nodefly.com>
Date: Wed, 28 Nov 2012 09:16:09 -0800 (PST)
Local: Wed, Nov 28 2012 12:16 pm
Subject: Re: How to find out *if* there is a memory leak?

NodeFly gives you a chart of Heap Usage and RSS.  There is also a chart of
Heap size calculated after each full garbage collection cycle.  If this
post-gc value continues to increase, you likely have a memory leak.  
NodeFly beta is free to use: http://www.nodefly.com

-mitch


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix E. Klee  
View profile  
 More options Nov 28 2012, 12:22 pm
From: "Felix E. Klee" <felix.k...@inka.de>
Date: Wed, 28 Nov 2012 18:22:02 +0100
Local: Wed, Nov 28 2012 12:22 pm
Subject: Re: [nodejs] Re: How to find out *if* there is a memory leak?

On Wed, Nov 28, 2012 at 6:16 PM, themitchy <mi...@nodefly.com> wrote:
> If this post-gc value continues to increase, you likely have a memory
> leak.

Doesn't make sense to me. I expect that value to fluctuate with the
number of client (browser) connections.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
themitchy  
View profile  
 More options Nov 28 2012, 12:53 pm
From: themitchy <mi...@nodefly.com>
Date: Wed, 28 Nov 2012 09:53:20 -0800 (PST)
Local: Wed, Nov 28 2012 12:53 pm
Subject: Re: [nodejs] Re: How to find out *if* there is a memory leak?

Number of connections is definitely part of the story.  NodeFly also
provides graphs of concurrent connections and throughput.

A fuller story might be: If your post-gc heap size goes up but your
connection count has not, then you may have a memory leak.

-mitch


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix E. Klee  
View profile  
 More options Dec 2 2012, 5:08 am
From: "Felix E. Klee" <felix.k...@inka.de>
Date: Sun, 2 Dec 2012 11:08:03 +0100
Local: Sun, Dec 2 2012 5:08 am
Subject: Re: [nodejs] Re: How to find out *if* there is a memory leak?

On Tue, Nov 27, 2012 at 9:26 PM, Joel Rolfe <jro...@gmail.com> wrote:
> I just put the following together on monitoring memory, and finding
> memory leaks. Very memwatch centered. Hope it helps:

> http://code.osnap.us/wp/?p=43

Thanks - that seems very helpful. Just left a comment.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »