-
Releasing memory immediately
Hello all,
Does anybody knows how to destroy (in C#) a non disposable object (an object that has not implemented a dispose method) so the memory used by it could be released immediately?
I tried setting the object value to null, but it doesn't worked!
I really appreciate any help.
Thank you all
-
What code are you using that isn't working?
Are you getting an error? If so, what?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Releasing memory immediately
Hello Hack,
I have to destroy a Dictionary object (System.Collections.Generic.Dictionary<TKey, TValue>) than contains the Key and as the value, it contains an object.
The thing is that even if I put null as the value of the object, I can't see the memory used to be released.
Unfortunately this code is repeated for every record in a datareader, so as the memory is never released, it continues to raise until we get an our of memory error.
the code is something like this:
dDataDictionary = new Dictionary<ID, myObject>
What I tried to do to release the memory was:
dDataDictionary = null;
but it doesnt worked....
Any ideas?
-
Try disposing of it
Code:
dDataDictionary.Dispose
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Releasing memory immediately
Hi Hack,
Unfortunately (and amazingly) dDataDictionary doesn't contains a "Dispose" method!!!.
The available options are:
Add
Aggregate<>
All<>
Any<>
AsEnumerable<>
AsQueryable
AsQueryable<>
Average<>
Cast<>
Clear
Comparer
Concat<>
Contains<>
ContainsKey
ContainsValue
Count
Count<>
DefaultIfEmpty<>
Distinct<>
ElementAt<>
ElementAtOrDefault<>
Equals
Except<>
First<>
FirstOrDefault<>
GetEnumerator
GetHashCode
GetObjectData
GetType
GroupBy<>
GroupJoin<>
Intersect<>
Join<>
Keys
Last<>
LastOrDefault<>
LongCount<>
Max<>
Min<>
OfType<>
OnDeserialization
OrderBy<>
OrderByDescending<>
Remove
Reverse<>
Select<>
SelectMany<>
SequenceEqual<>
Single<>
SingleOrDefault<>
Skip<>
SkipWhile<>
Sum<>
Take<>
TakeWhile<>
ToArray<>
ToDictionary<>
ToList<>
ToLookup<>
ToString
TryGetValue
Union<>
Values
Where<>
That's all...
-
Releasing memory immediately
Hello guys,
I could release the memory, but I think it's not the better way I could do it, so i would REALLY appreciate your help.
What I did is setting a null value to each object of the Dictionary object with an specific key, something like this:
dDataDictionary[kKey].Object1 = null;
dDataDictionary[kKey].Object2 = null;
dDataDictionary[kKey].Object3 = null;
The thing is, after assigning the null values to all the objects within dDataDictionary, I anyway have to "force" the memory to be released, and I did it using:
GC.Collect();
This way I can restore the memory to the same levels it was before starting the process that consume the resources (let's say it started with 60Mb, it raided to 180Mb, and afer GC.Collect(), it went back again to 60Mb).
If I doesn'tuse GC.Collect(), the memory is never released even if I assigned the null value.
I know it's risky to force GC to do it's job, so I would like to know if anyone has a better solution for this?
Thank you all.
Similar Threads
-
By computeruser in forum Architecture and Design
Replies: 1
Last Post: 07-08-2008, 02:22 AM
-
Replies: 11
Last Post: 11-16-2007, 12:23 PM
-
Replies: 0
Last Post: 11-02-2001, 04:22 PM
-
By Yang Du in forum ASP.NET
Replies: 4
Last Post: 07-03-2001, 05:26 AM
-
By Max Erixon in forum authorevents.pekowsky
Replies: 1
Last Post: 08-18-2000, 11:26 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks