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 #1030

Closed
dottodot opened this issue Sep 30, 2018 · 3 comments
Closed

Memory leak #1030

dottodot opened this issue Sep 30, 2018 · 3 comments

Comments

@dottodot
Copy link

I pretty sure I have a really big memory leak somewhere and not sure if it's something I've done wrong or an issue in feathers.

I'm using memwatch-next and it regularly report heap growth such as

Memory leak detected:
 { growth: 512,
  reason: 'heap growth over 5 consecutive GCs (12s) - 409.2 mb/hr' }

This is resulting in the app crashing fairly regularly

Unfortunately I'm no expert working out the cause but I've found one situation where the memory just seem to keep increasing.

Below is a service for file uploading

module.exports = function(app) {
  const s3 = new AWS.S3(app.get('spaces'));

  const blobStore = S3BlobStore({
    client: s3,
    bucket: 'boxxer'
  });

  const blobService = BlobService({
    Model: blobStore
  });

  // Initialize our service with any options it requires
  app.use(
    '/upload',
    multipartMiddleware.single('file'),
    function(req, res, next) {
      req.feathers.file = req.file;
      next();
    },
    blobService
  );

  // Get our initialized service so that we can register hooks and filters
  const service = app.service('upload');

  service.hooks(hooks);
};

with the following hooks.

module.exports = {
  before: {
    all: [],
    find: [],
    get: [],
    create: [
      hook => {
        if (!hook.data.uri && hook.params.file) {
          const file = hook.params.file;
          const uri = dauria.getBase64DataURI(file.buffer, file.mimetype);
          hook.data = { uri: uri };
        }
      }
    ],
    update: [],
    patch: [],
    remove: []
  },

  after: {
    all: [],
    find: [],
    get: [],
    create: [
      hook => {
        const Image = hook.app.service('image');
        return Image.create({ key: hook.key, format: hook.format }).then(
          image => {
            hook.result = image;
            return hook;
          }
        );
      }
    ],
    update: [],
    patch: [],
    remove: []
  },
};

Using chrome inspect i taken some snapshots while doing several uploads and one thing that keeps increasing is the strings. On the screenshots attached the thing that looks strange is when you view the details on the string the seem to be a never ending nested "event created"

screen shot 2018-09-30 at 11 56 03

screen shot 2018-09-30 at 11 56 15

@dottodot
Copy link
Author

OK I've found that leak is due to feathers-sync as removing that drastically reduces the amount of the leak

Can you move this issue or do I need to recreate

@dottodot
Copy link
Author

@lock
Copy link

lock bot commented Feb 7, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant