Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak in wascally.addExchange #98

Closed
mxriverlynn opened this issue Oct 22, 2015 · 0 comments
Closed

memory leak in wascally.addExchange #98

mxriverlynn opened this issue Oct 22, 2015 · 0 comments
Assignees
Labels

Comments

@mxriverlynn
Copy link
Contributor

My system uses the code API to dynamically create various exchanges, queues and bindings, based on configuration data in the system's database. As such, I can't use the wascally.config for more than a few key items in my system.

A few weeks ago, I noticed memory in my system slowly increasing and never decreasing... classic memory leak. After some drilling into things, I have isolated the problem in my app, and it comes down to the API calls for creating exchanges.

I've created a gist with a complete sample code set to reproduce the problem.

The gist of the gist, is this code:

for(var i=0; i< 1000; i++){

    wascally.addExchange("send-rec.exchange", "direct", {
      autoDelete: false,
      durable: true
    }).then(function(){
      wascally.publish("send-rec.exchange", {
        routingKey: "send-rec.key",
        type: "test",
        body: msg
      });
    });

  }

As I said, I have to dynamically determine exchanges, queues and bindings at runtime. This means I have to re-declare the exchange (at a minimum) every time I want to send a message. I know this is a performance bottleneck, and I'm ok with that given the relatively low number of messages we send.

But, this code will produce a memory leak.

Every time wascally.addExchange is called, more memory is eaten up and never released.

I'm going to try and dig into the Wascally code to figure out where the problem is. I could certainly use help, though. :)

Instructions To Reproduce The Memory Leak

I'm running OSX 10.11 (El Cap), Node v4.2.1

  1. copy all of the files from this gist into a folder
  2. npm install wascally
  3. node receiver.js
  4. node sender.js

wait until the messages are done processing, then

  1. ./send-more.sh (pid) where (pid) is the process id of the sender.js node process

this will send a kill -USR2 $pid signal to the sender, causing it to send another 1,000 messages.

watch the memory usage skyrocket

@arobson arobson added the bug label Oct 24, 2015
@arobson arobson self-assigned this Oct 24, 2015
@arobson arobson closed this as completed Nov 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants