Possible Duplicate:
How do i free objects in C#
my problem is i am using ..
video = new Video(vpath[a]);
video1 = new Video(vpath[a + 1]);
video2 = new Video(vpath[a - 1]);
to show 3 videos at same time on a winform.. and this in a function which is called by an button event … but it consuming to much memory …
i did this
video = null;
video1 = null;
video2 = null;
but its still not helping me out … how i can reduce the memory consumption by this 3 objects??
my question will be flagged as possible duplicate of
https://stackoverflow.com/questions/2406794/how-do-i-free-objects-in-c-sharp
but i still want to get over this thing bcoz i didn’t get help from that
Setting object to null does not mean that it won’t stay in memory until garbage collection will happen. You can explicitly call garbage collection (
GC.Collect()) but this is not desirable unless you don’t have another choice.You can use
disposeinstead of forcing garbage collection.And use instances of class with
usingstatement. Here is good answer how to use IDisposable pattern.