garbage collection - C# GC.Collect() and Memory -
i receiving large list method argument , remove memory after used. let gc thing, need careful of memory usage in app.
will code accomplish goal? i've read lot of differing opinions , confused.
public void save(ilist<employee> employees) { // i've mapped passed-in list var data = mapper<employee, employeedto>.maplist(employees); // ????????????? employees = null; gc.collect(); // continues process long running methods.... // don't want large list stay in memory } maybe should use technique i'm not aware of?
if list not used anymore gc automatically collect when available memory issue.
however, if caller uses list after passing function gc won't collect if set null (all have reference list - can't other objects hold references wel).
unless have measurable problem don't try , outsmart gc.
Comments
Post a Comment