Hi Guys,

@Phillip: I tried it now and it didn't work also.

@Stefan: this is because the data are sent in Chunks not one chunk, so I 
dont think req.body would work in this case.

The workaround I do now is that I null the variables after I finish using 
them, 

On Saturday, February 14, 2015 at 11:19:13 AM UTC+2, Stefan Thies wrote:
>
> Hi Karim,
>
> a) Is there any reason you don't use  req.body ? See Express 
> documentation. 
> b) The right way would be to attach the buffer to the request object , 
> e.g. when receiving first data event 
>      instead of having it living in the scope of your functions (which 
> remains all the time and might be the reason teh garbage collector can't 
> remove it).
>      This is what Express does with the req.body
>      
> BR
> Stefan
>
> On Friday, February 13, 2015 at 9:12:11 AM UTC+1, Phillip Johnsen wrote:
>>
>> Hi Karim,
>>
>> have you tried req.once('end', ...)?
>>
>> http://nodejs.org/api/events.html#events_emitter_once_event_listener
>>
>> - Phillip
>>
>> On Thursday, February 12, 2015 at 2:07:42 PM UTC+1, karim elsafy wrote:
>>>
>>> hi,
>>> I have a problem on my code, that some variables never deleted/released. 
>>> I tested it using heapdump. for example:
>>>     
>>>     var app = express();
>>>     app.post("/myURL", function(req, res){
>>>          var reqBody = new Buffer(0);
>>>          req.on('data', function (data) {
>>>                data = new Buffer(data);
>>>                reqBody = Buffer.concat([reqBody,data]);
>>>          });
>>>       
>>>          req.on('end', function () {
>>>               // use the reqBody and
>>>               // in some callbacks do the following line
>>>               res.send("OK");
>>>          });
>>>     )};
>>>
>>> here I found that variable reqBody never released (with some variables 
>>> in on end method) and the memory is grown for large data.
>>>
>>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/048b0a46-9d55-48b4-acf6-b0dbee21cac8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to