Async Shell Execute Leak

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.

<https://xojo.com/issue/60908>

For some reason, it keeps setting my bug reports to beta bug but its a current issue.

This is a bug in feedback that occurs if you are a member of the Pre-Release testers group.

Hi Alex,

Does that change if you change the mode to 2 (async) instead of 1? Async provides the same level of non-blocking.

[quote=496372:@Tim Jones]This is a bug in feedback that occurs if you are a member of the Pre-Release testers group.

Hi Alex,

Does that change if you change the mode to 2 (async) instead of 1? Async provides the same level of non-blocking.[/quote]

Yes, no matter how I configure the shell it seems to leak, event leaks without setting a handler, or doing anything other than execute.

Hmm, are you certain that this is wired memory and not cached file descriptors?

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 wouldn’t 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 don’t see to do anything.

Currently you’d have to put the reading code into a separate “helper” application, which you can then interact with via an async shell… Oh the irony…

I haven’t looked in the memory leak.

Post the link to the Feedback, and I’ll add some weight to it.

[quote=496451:@Sam Rowlands]Currently you’d have to put the reading code into a separate “helper” application, which you can then interact with via an async shell… Oh the irony…

I haven’t looked in the memory leak.

Post the link to the Feedback, and I’ll add some weight to it.[/quote]

<https://xojo.com/issue/60908>

Is that case private? Feedback on my system shows “No Results Found”, on the plus side it wiped out the cases I had open in the sidebar.

For some reason there is a bug that makes all feedback issues made by testers to be marked as beta bugs. I have requested that it be made public.

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 I’ve seen so memory leaks to speak of.

[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 I’ve 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.