I am a .net programmer, without much experience with unmanaged code. I am adding changes and additions to an unmanaged project, and everything works fine. Can you give me some guidance as to which code / objects I need to worry about garbage collection?
TIA
Missing. C ++ has no garbage collector.
In C ++, when allocating memory manually using an operator, newspecifying it frees this memory later (when it is no longer needed) using the operator delete.
new
delete
/ malloc/?
, , .
, , (new/malloc/createobject/globalalloc/sysstring/...)
MSVC (COM) ATL "RAII",CComPtr<>CComQIPtr<> , .
CComPtr<>
CComQIPtr<>
++ std::auto_ptr<>, boost/tr1 / ptr - , [], []
std::auto_ptr<>
COM. , AddRef() Release(), COM-, . COM .NET.
delete, .
karlphillip .
, -, .
,
delete foo; foo=null;
the next time you can check if it is zero, and otherwise delete them. And the best ... even if you try to remove the null pointer, nothing will happen! :)
Find out if the code uses smart pointers (probably this is the case), smart pointers must destroy the objects themselves when they go out of scope.
Source: https://habr.com/ru/post/1761957/More articles:Windows Identity Foundation Security Token Service cannot remain on the system - c #Is there a way to get the added int value in String in javaScript? - stringwindow batch file ends prematurely - batch-fileMnemonics for generic C # types - genericsdjango modeladmin list_display - pythonVisual Studio binding errors. An order that includes MFC, CRT? - visual-studioТекстовое поле ограничения ввода с JQuery - javascriptDelphi - event processing using end-to-end threads - multithreadingHow to select jQuery child with one selector? - jqueryUnable to decode JSON string in php - jsonAll Articles