Skip to content

SerialUSB cause memory leak after LowPower.sleep(), using ArduinoLowPower lib. samd21 cpu #293

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
Terryp44 opened this issue Jan 15, 2018 · 2 comments

Comments

@Terryp44
Copy link

Every wakeup causes some memory loss, eventually causing CPU reset. However if USB is not plugged in, no memory is lost.
using USBDevice.detach(); and USBDevice.attach();, open/close port does not help.
Using samd version 1.6.17
Test RAM memory usage via:
extern "C" char *sbrk(int i);
int FreeRam (void)
{
char stack_dummy = 0;
return &stack_dummy - sbrk(0);
}

@Terryp44
Copy link
Author

After reconnecting the SerialUSB port to the PC. samd CPU ram memory decreases by 592 bytes every sleep cycle.

@Terryp44 Terryp44 changed the title SerialUSB cause memory leak after LowPower.sleep(), using ArduinoLowPower lib SerialUSB cause memory leak after LowPower.sleep(), using ArduinoLowPower lib. samd21 cpu Jan 17, 2018
@Terryp44 Terryp44 reopened this Jan 17, 2018
facchinm added a commit to facchinm/ArduinoCore-samd that referenced this issue Jan 17, 2018
USB Configuration was meant to run only once, but if the board comes back from standby the host can reconfigure the device again.
Probably a cleaner patch could be free()-ing the buffers on standby() to release the memory but at least we don't leak anymore.

Fixes arduino#293
@facchinm
Copy link
Member

Hi @Terryp44 ,
I pushed #295 to solve the issue. Can you test the produced json and confirm that the standby "dance" doesn't leak anymore? Thanks!

sandeepmistry pushed a commit that referenced this issue Jan 25, 2018
USB Configuration was meant to run only once, but if the board comes back from standby the host can reconfigure the device again.
Probably a cleaner patch could be free()-ing the buffers on standby() to release the memory but at least we don't leak anymore.

Fixes #293
@sandeepmistry sandeepmistry added this to the Release 1.6.18 milestone Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants