Re: Creating my on variable
From: Richard Blewett [DevelopMentor] (richardb_at_NOSPAMdevelop.com)
Date: 11/10/04
- Next message: germanov: "Re: Dotnet versus Java-Applets"
- Previous message: Roby E Martins: "Re: Creating my on variable"
- In reply to: Roby E Martins: "Re: Creating my on variable"
- Next in thread: Jon Skeet [C# MVP]: "Re: Creating my on variable"
- Messages sorted by: [ date ] [ thread ]
To: microsoft.public.dotnet.framework Date: Wed, 10 Nov 2004 12:08:50 -0800
The
var = new Roby();
simply reinitializes the memory of var, it doesn't perform a new allocation.
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
nntp://news.microsoft.com/microsoft.public.dotnet.framework/ Jon,
Ok, I tried a simple application to test your arguments.
I created a struct with a variable
And declared two structes as that struct.
The first with a value (=5) and second referent with the first one, so
everything that happends in the same memory space will be changed in the
second too.
Now I execute NEW in the first one.
Look what happend. The second still pointing to the same memory space
and have the last value that we had set (=5).
But the First one has 0 as value.
"NEW" always create a new instance in memory. To class and structs.
So, when I'm executing a new in the operator, I'm creating a new
instance from my variable(struct) and send the reference to the called
variable.
Calling ( a = 1) with execute ( (Operator ... ) return new
Roby.Integer(1) )
Sample:
namespace ConsoleApplication1
{
struct Roby
{
public int I;
}
class Program
{
static void Main( string[] args )
{
Roby Var;
Var.I = 5;
Roby Var2 = Var;
Var = new Roby();
System.Console.WriteLine( "VAR : {0}" , Var.I );
System.Console.WriteLine( "VAR2 : {0}" , Var2.I );
System.Console.Read();
}
}
}
Relevant Pages
... I've tried a few memory leak detectors, and two of them show some promise. ... MemBlockCount: LongInt = 0; ... cmp eax,edx ...
(alt.comp.lang.borland-delphi)
... How do i free memory in Javascript? ... saleDate = new Date; ... references to it are released) the memory is freed by the garbage collector. ...
(microsoft.public.scripting.jscript)
... You are trying to create a persistent block of memory which stores ... // memory used by PNewRec pointers ... so it may not compile or there may be some syntax errors etc. ...
(borland.public.delphi.language.objectpascal)
... PHP has not application var, and not multi thread ... the only way is database, share memory. ...
(php.general)
... Roby E Martins wrote: ... > implict operator INT to Roby.Integer and then I'm must create a new ... new value or not - it'll have the same memory characteristics. ...
(microsoft.public.dotnet.framework)