Hello. As far as I know, the OS itself allocates memory for the heap, but how then to work with memory if we don’t know how much it is in the heap?

  • one
    You can ask the OS how much we have. - KoVadim 7:09 pm
  • The question is not clear. What exactly do you want to know? Heap memory is allocated and released as needed. Highlight and work on health. - AnT
  • How much memory is initially available? And is it possible to learn this with the help of any functions? - 0xFFFF
  • And what does it matter how much it is at the beginning. if it turns out not only that the malloc functions were initially given, they themselves take care of requesting an additional OS and so on until all the RAM in the system runs out, including the place in the swap file - Mike
  • The OS itself does not allocate anything. She has to kick hard. But in c ++, the memory allocator, which is called by new / delete operators, does this for you. If there is not enough memory, he will inform you about this by throwing the exception std::bad_alloc . - VTT

0