Suppose you want to write a high-performance method that processes a large data set. Why should developers not enable manual memory management, and not force a switch to C or C ++?
void Process() { unmanaged { Byte[] buffer; while (true) { buffer = new Byte[1024000000]; // process delete buffer; } } }
, ( , GC) , , . GC, , .
, #, , , :
void Process() { unsafe { byte* buffer; while (true) { buffer = Marshal.AllocHGlobal(1024000000); // process Marshal.FreeHGlobal(buffer); } } }
, , C/++, # - buffer[i] buffer+i .
buffer[i]
buffer+i
, , , C ++. .
: . , , , ++, .
. , , , . #, #. , . , , , , C ++, . ( ++, , #. .)
, . C90 , Fortran , C- . , .
# , . , -, . , , . , .
, - , : , . .
, ?
.NET , , . , ( ), , , .
, , , .
, , , , GC , ( ) , .
For the same reason, most cores will not allow you to plan your own threads. Since you really don't need 99.99 %% of time, and exposing this functionality, the rest of the time will only tempt you to do something potentially stupid / dangerous.
If you really need fine grain memory management, write this section of code in something else.
Source: https://habr.com/ru/post/1725074/More articles:Configuring Drupal modules from another module - drupalReading tag data for Ogg / Flac files - cboost :: asio multithreaded problem - c ++How do I associate a dependency property with a user interface for a Silverlight user control? - silverlightHow to trigger an event at 03:00 every night? - c #Database design whose table has a foreign key - sqlSIGSEGV, (по-видимому) вызванный printf - cFlex / Action Script quick question - Excessive import - flexDjango: fill out the get method form - djangoA call with a single instance of a stored procedure - sqlAll Articles