Skip to content

Identifier parsing creates to many new objects #612

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

Closed
ekryvoshey opened this issue Oct 25, 2017 · 3 comments
Closed

Identifier parsing creates to many new objects #612

ekryvoshey opened this issue Oct 25, 2017 · 3 comments

Comments

@ekryvoshey
Copy link

ekryvoshey commented Oct 25, 2017

Hello!

I have a problem: my BeaconLayout is like this "m:0-1=7502,p:3-3,i:0-1,i:4-14,i:15-24". Identifier's summary length is pretty long, and it causing Indetifier object to create too many bew Object during toHexString() execution. And that causing to many garbage collection in the app, UI thread is constantly interrupting with GC so I have UI lag every time I'm receiving beacon colection.

https://drive.google.com/open?id=0B_546mjMnsJ9d2QyazJyc1FraU0

As far as I remember, data fields could be an alternative, but aren't they limited to 4 bytes? Perhaps you can suggest different solution to this?

@davidgyoung
Copy link
Member

Yes, data fields are limited to four bytes.

It sounds like the proper answer is to simply optimize the toHexString() method of the Identifier class so toString() isn't so expensive for identifiers that aren't two bytes or 16 bytes.

At first glance simply replacing String.format("%02x", item) with code that doesn't use the heavy-weight String.format method might improve things quite a bit. Here's one such proposed implementation: https://stackoverflow.com/a/32123766/1461050

@ekryvoshey, do you want to try benchmarking a replacement method implementation to see if you can come up with something faster? If so, I'll put it into a test release for you to try.

@ekryvoshey
Copy link
Author

ekryvoshey commented Oct 25, 2017

Yes, I would like to try and replace logic to something lighter. If you can assist, it would be great!

P.S. My itention is to get raw bytes array as Identifier so I can store it as a BLOL in my DB.

@davidgyoung
Copy link
Member

Fixed in #615

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