Memory management/leak in PowerShell, but not in PowerGUI ScriptEditor RRS feed

  • Question

  • This seems wierd, so tell me if you have seen it...

    I have a PowerShell script that reads/parses log files.  Once I turned it loose on a large number of files the system slowly came to a halt, out of memory.  Without a lot of detail, each log file is 10MB, and is read as Import-CSV then looped through.  Each iteration of a log file increases the memory consumption of PowerShell by about 160 MB.

    I use PowerGUI ScriptEditor as a debugger.  When I run the same script, on the same data, within PowerGUI, overall memory consumption for the process stays between 300 and 400 MB for the full run of the script.

    I'd like to run this in PowerShell, but I'm not sure where to start troubleshooting...

    Friday, October 10, 2014 8:57 PM


  • Hard to know what the problem might be without seeing the script.

    In this case I recommend writing a short script that contains only the absolute minimum amount of code needed to reproduce the problem. You should also write a script that creates a data file that demonstrates the problem in action (for example, a loop construct that generates a large data file).

    The goal is to provide code and data that causes the exact same problem for respondents as it does for you.

    -- Bill Stewart [Bill_Stewart]

    Friday, October 10, 2014 9:14 PM