none
Script consumes GBs of RAM RRS feed

  • Question

  • I have a script that uses Get-ACL to read the file system permissions on a folder, then enumerates the group membership (including cross domain nesting).  (Very normal stuff).

    I am using objects to:
     - Store gathered information
     - Store a copy of the previously gathered information
     - Store calculated differences for processing into database

    The script when run comsumes GBs of RAM and gets slower and slower as it does so.  I am looking for advice on how to reduce this?

    Reading around I believe I should make more use of the pipeline - however I'd have to re-write the script and loose a lot of readability if I did this, so I would rather not at this point.

    Might I benefit from regularly removing then re-creating my object variables?  (Created using New-Object System.Collections.ArrayList).  Would Remove-Variable do this properly?  My testing suggest this will not help.  Having allowed the script to complete, then removed various variables I have seen no reduction in RAM usage by ISE.

    I am using Compare-Object.  Could there be something around this populating inbuilt variables of the differences that are slowly consuming RAM?  Is there anything I could do to reduce\limit\housekeep this?

    My only other thought is to try and break the script further - a 'parent' script to get the list of things to process, then a 'child' script to be called for each area to process.

    TIA

    • Moved by Bill_Stewart Friday, March 9, 2018 7:25 PM Unanswerable drive-by question
    Wednesday, September 6, 2017 9:01 AM

All replies

  • It may be the bulk of data you are storing and processing, maybe using pipelines and/or log files to save results to disk as you go rather than in memory?

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

    • Proposed as answer by I.T Delinquent Wednesday, September 6, 2017 11:23 AM
    Wednesday, September 6, 2017 10:03 AM