S
S
Sasha_882016-05-27 21:14:10
C++ / C#
Sasha_88, 2016-05-27 21:14:10

When malloc() or new is called, is some win api function actually being called?

And when deleting too? And now it’s interesting, but how to make a small heap so that memory is allocated within this small heap only?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2016-05-27
@Sasha_88

When malloc() or new is called, is some win api function actually called?

No not always. In most cases it is not called. The system call is executed only if the current block managed by the s-heap (i.e., s-s runtime) is exhausted. If a system call were made every time, you would not wait for the results of your program.
See above.
You allocate a block of memory in any of the ways you know, declare functions a la myalloc and myfree, and implement one of the free space management algorithms on the heap (for example, binary partitioning).
In C++, you can redefine the new and delete operators.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question