i developed in c#. after period used windowsforms, switch wpf. after time of developing realized application needs more time reduce memory consumption after running high process. winforms had no problem it. analyzed memory profiler , found wpfgfx_v0400.dll reserved memory , after not reduced. question function of library. know native wpf library , in context of graphic rendering in specially controls of wpf or object called library?
as quick fix can use method clear memory leak
public class memorymanagement { /// <summary> /// clear un wanted memory /// </summary> public static void flushmemory() { try { gc.collect(); gc.waitforpendingfinalizers(); if (environment.osversion.platform == platformid.win32nt) { setprocessworkingsetsize(system.diagnostics.process.getcurrentprocess().handle, -1, -1); } } catch (exception e) { } } /// <summary> /// set process working size /// </summary> /// <param name="process">gets process</param> /// <param name="minimumworkingsetsize">gets minimum working size</param> /// <param name="maximumworkingsetsize">gets maximum working size</param> /// <returns>returns value</returns> [dllimportattribute("kernel32.dll", entrypoint = "setprocessworkingsetsize", exactspelling = true, charset = charset.ansi, setlasterror = true)] private static extern int setprocessworkingsetsize(intptr process, int minimumworkingsetsize, int maximumworkingsetsize); } add class application , call flushmemory method met memory leak.
Comments
Post a Comment