Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Memory management fix | Adding max number of active threads #2

Open
wants to merge 2 commits into
base: solution
Choose a base branch
from

Conversation

melloc01
Copy link

hey @cameronwp

I had to bump node-sass version to get the solution branch to work, not sure why tho.

};
};

var QRCodeManager = function(element) {
this.numActiveThreads = 0;
this.maxThreads = 4;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 4?

Copy link
Author

@melloc01 melloc01 Dec 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an arbitrary number - good question hehe
A better approach could be:

  this.maxThreads = window.navigator.hardwareConcurrency || 4;

https://developer.mozilla.org/en-US/docs/Web/API/NavigatorConcurrentHardware/hardwareConcurrency

I'll update the PR tonight

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!

qrCodeManager.showDialog(url);
}
});
if (qrCodeManager.numActiveThreads < qrCodeManager.maxThreads) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if numActiveThreads is over maxThreads? does the frame get dropped?

Copy link
Author

@melloc01 melloc01 Dec 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The consequence is: The worker won't be called.

On my i5 it takes about 10ms for the worker to respond back, at the worst case scenario we'll have a "10ms lag", ** 2.5ms** on the best case, not noticeable.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool cool. thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants