cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to clear Collection?

BenjaminBechto1
Level 2
In paragraph Process or Object design considerations of https://help.blueprism.com/Operational-Support/Performance/Routine-Maintenance/1141009962/How-do-I-diagnose-and-avoid-Out-Of-Memory-issues.htm developers are advised to clear Collections after usage with "Remove all Rows". Another possibility would be to assign an empty Collection to the Collection to be cleared. My Questions: - Which is better regarding performance and memory consumption? - What happens behind the scenes in "Remove all Rows"? Is DataTable.Clear() called on the Collection itself? Thanks to all responders!
1 REPLY 1

AndreyKudinov
Level 10
Assigning new empty collection is probably the fastest way. Remove all Rows if you need to preserve fields, but you can just keep an empty copy. p.s. My limited investigation tells me that you need to clean up memory in VBOs too, otherwise it is not released after process end until you initialize that VBO again in another process. None of the default VBOs do that. For example, Append rows in Collection manipulation will leave behind two copies of the data in memory. If another process runs that never uses that VBO - that memory seems to stay unavailable (even after GC.Collect). If you change Collection manipulation to empty all collections on clean up (or with an action) - memory is reclaimed - resource pc process returns back to where it started on memory consumption.