Limiting Memory Usage
Typically the process memory usage will grow and not shrink unless there is enough pressure for the .NET garbage collector to release unused memory back to the operating system. This is due to memory allocations being an expensive operation.
This can become a problem on systems where other critical services compete for finite memory resources - especially when EzeScan REST Sync is configured to fetch large CSV files from SFTP as the entire file must be allocated to memory (unlike local files that can be streamed).
To overcome this issue we can apply an override to EzeScan.RestSync.runtimeconfig.json
to force the .NET garbage collector to aggressively releasing unused memory when the overall system memory is above a given a percentage. In The example below we are setting System.GC.HighMemoryPercent
option to 60%.
Setting the threshold too low can negatively impact the performance due to frequent memory allocations and deallocations.