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 - Fix Found #6

Open
reubenstr opened this issue Sep 3, 2023 · 0 comments
Open

Memory Leak - Fix Found #6

reubenstr opened this issue Sep 3, 2023 · 0 comments

Comments

@reubenstr
Copy link

A memory leak is caused by not deleting the Adafruit_I2CDevice object in the deconstructor.

In begin() line ~66 an Adafruit_I2CDevice object is newed:
i2c_dev = new Adafruit_I2CDevice(SHTC3_DEFAULT_ADDR, theWire);

The deconstructor fails to delete this object.

Adding the following in the deconstructor prevents the memory leak:
if (i2c_dev) { delete i2c_dev; // remove old interface }

The issue affects programs that call the library in a local method and the class goes out of scope in a looping fashion.

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

1 participant