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

Reduce memory footprint of logging library #212

Closed
odyodyodys opened this issue Jun 4, 2017 · 1 comment
Closed

Reduce memory footprint of logging library #212

odyodyodys opened this issue Jun 4, 2017 · 1 comment
Assignees
Labels
bug Bug that is caused by the library
Milestone

Comments

@odyodyodys
Copy link

odyodyodys commented Jun 4, 2017

Summary

The logging library does a lot even when logging is disabled (or partially enabled) and increases the memory footprint of RxAndroidBle for no particular reason. The same issue has been fixed in the library RxBleLog is based on.

Preconditions

Set log level other than VERBOSE

Steps to reproduce actual result

Communicate with a ble device.

Actual result

There are numerous log calls which is great. But even when log level is set to Error or None in production, log messages are created and waste a lot of cpu cycles and ram.

Eg:
RxBleGattCallback.onCharacteristicWrite() calls
RxBleLog.d("onCharacteristicWrite characteristic=%s status=%d", characteristic.getUuid(), status);
which in turn calls
throwShade(Log.DEBUG, formatString(message, args), null); which calls formatString even though the message will not be logged.
and lastly throwShade discards the message.

Expected result

in RxBleLog the call to formatString should be inside throwShade and after the check for logging level.

The point is that a lot of work is done without a reason. One can argue that its only strings being created, but since VERBOSE and DEBUG also use this, it can easily waste a big amount of cpu cycles on applications with a lot of communication with ble devices.

The logging library this is based on, Timber, has this fixed.

@dariuszseweryn dariuszseweryn self-assigned this Jun 5, 2017
@dariuszseweryn dariuszseweryn added the bug Bug that is caused by the library label Jun 5, 2017
@dariuszseweryn dariuszseweryn added this to the 1.2.4 milestone Jun 5, 2017
dariuszseweryn added a commit that referenced this issue Jun 5, 2017
… will not be done when log is disabled. #212

Reviewers: pawel.urban

Reviewed By: pawel.urban

Differential Revision: https://phabricator.polidea.com/D2400
dariuszseweryn added a commit that referenced this issue Jun 5, 2017
@dariuszseweryn
Copy link
Owner

dariuszseweryn commented Jun 5, 2017

Fix should be available in 1.2.4 shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that is caused by the library
Projects
None yet
Development

No branches or pull requests

2 participants