|
That would be my guess. What I know for sure is that if you call dispose, you'll find your memory situation does not deteriorate where you use a lot of large objects.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian, for your help.
Devin
|
|
|
|
|
The dispose pattern if implemented correctly should supress calling the finalize method of the object. The GC when collectiong objects always calls the finalizer of these objects, but if dispose is implemented and the object has been disposed, u might gain this small advantage in performance allthough its probably insignificant.
The main advantage is as been stated before, the release of unmanaged resources and the fact that ur helping the gc manage memory in a more efficient way.
|
|
|
|
|
Here is how it works:
you have a reference to your ".net" object instance
the memory that object occupies is released by the GC when no references are left.
Dispose is used to release native resources , such as filehandles , db connections or memory allocated by some native resource.
so ".Dispose" does not kill the .net object itself , it just tells it to drop its expensive resources.
if you are working with images , eg in DX there are plenty of unmanaged resources behind the scenes , and your .net object is told to drop those directly ... therefore Christian get a big chunk of memory back.
if your object does not hold any references to any native resources (directly or inderectly) you will not gain anything by implementing idisposable on that class.
eg if your class has a big arraylist or array and you set it to null in your dispose method , you will not gain anything since those are managed resources taht will be released by the GC.
//Roger
|
|
|
|
|
I am trying to convert the following code to C# and am having quite a bit of difficulty.
#ifndef API
#define API
#define API_Item 256
Here is what I tried:
#if (!_API)
#define API
public static readonly int API_Item = 256;
Am I way off?
|
|
|
|
|
|
|
I'm trying to implement highlighted/selected text format editor funtions by clicking buttons like "bold", "italic", etc.
The problem is how could I get highlighted text from certain textbox?
|
|
|
|
|
string ht = textBox1.SelectedText;
but about formatting you may use richtextbox.
|
|
|
|
|
yeah, you have to use a richTextBox. and with the rich formatting, you could do something like:
richTextBox1.SelectionColor = colors.blue;
that sort of thing.
|
|
|
|
|
Thank you for your reply.
Unfortunally, my code is for a web application but not windows so that I cannot use richtextbox.
And I work on vs2003, which doesnt provide "selectedtext" function for textbox.
But I found a way could solve the problem by javascript pbbly.
|
|
|
|
|
I have an Excel automation engine that collects data from a specified cell in the Execel worksheet. Well when I get the data back and parse it based on a "," I get the following string from the worksheet "\"devbng:BNGDetail\"". Well I need to get rid of the '\' and the extra '"'. Well I have tried everything i could think of
I wrote the following
_serverName.Replace("\\","");
_serverName.Replace('\"',' ');
But no avail, well any help would be greatly appreciated.
Thanks
|
|
|
|
|
There's a Remove method also, isn't there ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ignore this entire post if _serverName is not a string object.
Strings are immutable, so the code you have now is essentially a no-op, i.e. it's returning a new instance of a string that is not being stored by anything, and the original value of _serverName is unchanged. Have you tried:
_serverName = _servername.Replace("\\", "");
|
|
|
|
|
Hi,
After I am done with the object, when I set that object to null, what I am doing there. (Is it, I am setting manually no references to the object or I am reclaming the memory used by the object or I am doing both)
Thanks
Devin.
|
|
|
|
|
devin123 wrote:
After I am done with the object, when I set that object to null, what I am doing there.
You are setting the reference to the object to null, not the object itself. If there are no references to an object the garbage collector can remove the object from memory. If the reference is a local variable then when the method goes out of scope the reference will no longer exist and the object (assuming no other references) will get cleaned up.
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
|
Hi,
I know GC does memory management manually. If i want to manually reclaim the memory of an object, how can I do it.
Thanks
Devin
|
|
|
|
|
|
Then what does, GC.Collect() do
what is differnce between them
Devin
|
|
|
|
|
|
I think using GC.Collect we achieve finalization not memory reclaimation. Is I am right. Explain.
|
|
|
|
|
It will reclaim the memory. If an object requires it then the finaliser will be called first. The finalisation process is inefficient and objects that have finalisers will also have a Dispose() method. So, you should call Dispose() on an oject if it has that method. The Dispose() method will generally suppress the finalisation on that object making garbage collection more efficient.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Thka colin for your help.
|
|
|
|
|
hey everyone,
I've been searching for a way to get an array that includes every directory within a selected directory. say the parent directory was called "hello", I want to get every directory, even the directories within the directories returned. (i.e. hello/hieveryone/helloagain/). There is a "Directory.GetDirectories" method, but this only returns the directories immediately below the selected one. How do I get all the ones below that one, and below that one and send them to an array? all the levels below would be nice, but atleast a minimum of 12 levels below the directory. sry for the wordiness, I didn't know how else to word it. thanks a lot for your help!
|
|
|
|