I have a leak of about 29-37 bytes when calling Shell.Execute in async mode (mode 1). Seems to happen in Desktop/Console/Web on macOS/ARM/Linux. I read a “file” many times per minute (ADS1015 ADC) with “cat” as reading via BinaryStream or TextInputStream causes blocking. In less than a day, the program has leaked about 200MB and I don’t know what to do. Tested on the latest release but I use 2019r1.1 as anything newer is broken for me in other ways.
I am using Runtime.MemoryUsed to see the memory usage. Even when I call Shell.Execute with something simple like echo something it is still leaking. If it was caching I wouldnt expect it to keep saving 36 bytes at a time all the way up to 250+ MB leaked.
@Alex Bombay, if you’re on macOS or Linux, are you able to read that file using tail -f filename? If so, you can use an async shell and it’ll fire the DataAvailable event whenever there’s new data. It is way more efficient than using cat.
The leak happens no matter what I run in Shell.Execute, I use cat because I am reading an ADC on raspberry pi that is setup using overlays. I also want to be able to control when I poll it, is there a better way to read files without blocking the UI? Threads dont see to do anything.
[quote=496473:@Greg O’Lone]Using tail would require only one call, so unless the leak is occurring in the DataAvailable event, I would imagine it would help greatly.
FWIW, I use this technique for some internal apps that monitor system logs on Linux servers and Ive seen so memory leaks to speak of.[/quote]
I am reading an ADS1015 via an overlay for a dimmer and color scheme control, it shows up as a file in “/sys/devices”. Using tail -f only gives me one value and doesn’t update. I would like the ability to adjust the update rate based on the time since the last change, right now reading a via cat and async shell works well other than the leak that will cause the app to crash in less than a few days. Do you have any idea where that leak might be coming from? This program should run for a long time without restarting. I use async shells everywhere including helper apps so it’s going to be a big problem for me.
I feel like I’m building a Jenga Tower here… I have now wrapped an interactive shell (mode 2) with my own “AsyncShell” that when created it executes “tee | bash” to redirect all “Shell.WriteLine” into bash. “AsyncShell.Execute” wraps each command with a header/footer to know when it’s complete and where the result starts/ends. There’s a couple of oddities and its not very resource-efficient especially on a raspberry pi, but I would rather eat some RAM and CPU than have it die in less than 2 days.