Preamble:
Please do not move this thread on "Windows programming" cause I am a C programmer under Linux who needs to make some code also under Windows but this question IS NOT on strictly-Windows matters. It is instead about Garbage Collector and Managed Heap Objects and variables, which is somethiong more general than just Windows matters.
Problems:
(1) When I alloc on the Managed Heap a new instance of var/obj. with something similar to
is there a method I can call to explicitely free the resource when not needed or do I have to let this be done by the garbage collector?Code:public ref class Form1 : public System::Windows::Forms::Form { public: InitializeComponent(); Initialize(); } .. .. private: System::String^ Str; .. .. void Initialize(void) { .. this->Str = gcnew System::String("");
(2)
In another example
I did not have to use gnew cause this is implicitely called (I have been told in another thread) by String::FormatCode:private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { System::String^ TempStr; .. .. TempStr=String::Format("DataLen= {0:D}\n",Req.DataLen); textBox4->AppendText(TempStr); .. ..
Where is it easy to the find the answer to this question: a method calls implicitely gcnew or not?



LinkBack URL
About LinkBacks




