Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you're going to be moving objects around in memory then you can't do this fully generically. You will only be able to do this with objects that <em>know</em> that they might be moved. You also will need a locking mechanism. When a function is being called on an object, then it can't be moved.</p> <p>The reason is that the whole C++ model relies on objects sitting at fixed points in memory, so if a thread was calling a method on an object, this thread was paused and the object moved, disaster would strike when the thread resumed.</p> <p>Any object which held a raw memory pointer to another object that might be moved (including a sub-object of itself) would not work.</p> <p>Such a memory management scheme may work but you have to be very careful. You need to be strict about implementing handles, and the handle->pointer locking semantics.</p> <p>For STL containers, you can customize the allocator, but it still needs to return fixed raw memory pointers. You can't return an address that might move. For this reason, if you're using STL containers, they must be containers of handles, and the nodes themselves will be ordinary dynamically allocated memory. You may find that you too much in overhead in the handle indirection and still have problems in the fragmentation of the handle collections than you gain by using STL.</p> <p>Using containers that understand your handles directly might be the only way forward, and even then there may still be a lot of overhead compared to a C++ application that uses traditional objects fixed in memory.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload