chapter12, Is the buffer a stack or a vector?

If you can use memory management by object, you may have to consider about using a stack or a vector for buffers used only on the spot.

Of course, bugs in the memory system can cause serious situations, so there is a rule that if object can be used, stack buffers that directly manipulate memory should not be used. For example, if you make a mistake with a vector, an exception error will be thrown immediately, so it is easy to notice bugs.

However, for a small buffer of processing, I think that a stack is fine. The stack uses the fixed memory allocated to the thread as it is, so another allocation by the heap does not occur. The higher count of call, the faster the speed. In addition, the stack is allocated on a per-thread basis, so you can use it without worrying about multi-threading.

暗号通貨短編