3 ms·
Memory is just one kind of resources. Games do tons of I/O, often gigabytes/second. To illustrate, any PC game has a lot of places which call GPU driver like th
by Const-me 7y ago
Memory is just one kind of resources. Games do tons of I/O, often gigabytes/second. To illustrate, any PC game has a lot of places which call GPU driver like this:
D3D11_MAPPED_SUBRESOURCE mapped;
context->Map( buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped );
// Write memory address pointed by mapped.pData
context->Unmap( buffer, 0 );
With C++ RAII, you can do something like that instead:
MappedBuffer mapped{ buffer }
// Write memory address pointed by mapped.pData.
// No need to do anything else, the destructor of MappedBuffer will unmap.
- ncmncm 7y agoThis. Freeing memory is the least important job for destructors.