Discussion experiment on memory release

xiaoxiao2021-03-06  23

I have seen a article on the memory release of memory in Flash, so I did the following experiment.

Var newPerson: Person = New Person ("Nate", 32);

Var Person_1: Person = New Person ("Nate", 32);

Var Person_2: Person = New Person ("Jane", 28);

Trace (Person_1.ShowInfo ());

//out.print: My name is: Nate, my age is: 32 years old

Trace (Person_2.showinfo ());

//out.print: My name is: Jane, my age is: 28 years old

TRACE (NewPerson.ShowInfo ());

//out.print: My name is: Nate, my age is: 32 years old

VAR PRESON_0 = NewPerson;

NewPerson.age = 26;

NewPerson.name = "RERD";

TRACE (NewPerson.ShowInfo ());

//out.print: My name is: RD, my age is: 26 years old

TRACE (Preson_0.showinfo ());

//out.print: My name is: RD, my age is: 26 years old

TRACE (PRESON_0.AGE);

//out.print:26

Trace (PRESON_0.NAME);

//out.print:rerd

// *** You can see a copy of the copy from it, just point the new object to an address of the memory.

//

DELETE NewPerson;

TRACE (NewPerson.ShowInfo ());

//out.print:undefined

TRACE (Preson_0.showinfo ());

//out.print: My name is: RD, my age is: 26 years old

// *** Although the first object is deleted, because there is still an object pointing to the memory address, the memory is still not released.

TRACE (PRESON_0.AGE);

TRACE (PRESON_0.NAME); So delete does not necessarily release memory

转载请注明原文地址:https://www.9cbs.com/read-81037.html

New Post(0)