Can anybody perhaps tell me how I can resolve this, if it’s something I’m doing on my end!? I basically have a simple console application. I noticed that when calling multiple shell commands, my application’s memory consumption started to climb… and continued to do so until I quit the application. Here’s what I know:
These two functions together (basically me just handling the shell command in an external method, which I’ve simplified for verification) leads to a memory leak:
[code]Function processShell(shellCommand as memoryBlock) As memoryBlock
dim systemShell as new shell
systemShell.execute(shellCommand)
return trim(systemShell.result) 'return trimmed results
End Function
Function Run(args() as String) As Integer
const THREAD_IDLE_INTERVAL = 128
coreSystem = new systemFramework
// - keep main thread running
do
app.doEvents(THREAD_IDLE_INTERVAL)
stdOut.write coreSystem.processShell(“ps aux | grep myApp | grep -v grep”) + endOfLine
loop
End Function[/code]
If I just handle the shell command in the run event itself, no memory leak:
[code]Function Run(args() as String) As Integer
const THREAD_IDLE_INTERVAL = 128
dim testShell as new shell
// - keep main thread running
do
app.doEvents(THREAD_IDLE_INTERVAL)
testShell.execute(“ps aux | grep myApp | grep -v grep”)
stdOut.write testShell.result + endOfLine
loop
End Function[/code]
What do you think is going on? I like to use memoryBlocks instead of string so I can manipulate the data easier if necessary, but changed those to string and still have the memory leaks. I’ve also passed the shell response to a string variable, nullified the shell object before leaving the external method and passed the resulting string, and same issue.