A quick google search should give you several good articles on finding
memory leaks in node.  There have also been discussions here which you can
search.

I have never seen anything written about minimizing memory usage.  Maybe
someone else can help.  This may be obvious, but the only thing I can think
of is to make sure your variables go out of scope so they are
garbage-collected, especially the big ones.  Because of closures it can be
easy to accidentally keep something in scope.  A closure is created every
time a function is created and as long as that function is kept then all
the closure data is kept.

globalObj = {};

globalObj.func = function () {
    bigArray = [];
    for (i=1; i<1e6; i++) bigArray.push(i);
    return function () { console.log(bigArray.length)  };
}()

You might thing bigArray is local and will be garbage collected.  However,
it is in the closure for the tiny function stored in globalObj.func so it
will occupy memory as long as globalObj.func stays around.


On Sat, Mar 24, 2012 at 9:45 PM, 李白|字一日 <[email protected]> wrote:

> yes.
>
> one problem is about memory leak,
> another is how to minimize the usage of the memory.
>
> thanks.
>
>
> 2012/3/25 Mark Hahn <[email protected]>
>
>> I think you are going to have to make your question more specific.  Are
>> you concerned about finding memory leaks?
>>
>> On Sat, Mar 24, 2012 at 10:15 AM, 李白字一日 <[email protected]> wrote:
>>
>>> thx
>>>
>>> --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>
>>  --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to