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

CPU overload caused by Heartbeat-Monitor's timer #285

Open
LironGiniApps opened this issue Mar 5, 2017 · 1 comment
Open

CPU overload caused by Heartbeat-Monitor's timer #285

LironGiniApps opened this issue Mar 5, 2017 · 1 comment

Comments

@LironGiniApps
Copy link

In the file SRKeepAliveData.m there's a calculation in order to determine what is the _checkInterval.

_checkInterval = [NSNumber numberWithInteger:(([_timeout integerValue] - [_timeoutWarning integerValue]) / 3)];

In our case, the server is sending keepAliveTimeout == 6.
So, after calculating the _checkInterval, the result is 0 because the code uses numberWithInteger and also integerValue (instead of using doubles) while trying to pull the data into the Heartbeat Monitor's timer.

When _checkInterval is equals to 0, that means that the Heartbeat Monitor's timer is instantiated with timeInterval == 0, which causes the timer to run every 0.001 seconds and finally a serious CPU overload.

The code for instantiating the timer is in file SRHeartbeatMonitor.m line 50:

_timer = [NSTimer scheduledTimerWithTimeInterval:[[[_connection keepAliveData] checkInterval] integerValue] target:self selector:@selector(heartbeat:) userInfo:nil repeats:YES];

Thank you very much,
Liron.Y

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

No branches or pull requests

2 participants
@LironGiniApps and others