Is there a way to set the memory limit to the value specified in C++?

Asked 1 years ago, Updated 1 years ago, 304 views

The memory limit for competitive programming is 1024M, and I would like to prevent further memory usage. Please let me know if there is a compiler option that can do this.

c++

2022-11-28 06:52

2 Answers

Can't I use Visual Studio debugs to measure memory usage?


2022-11-28 06:58

With C++, memory retention and release are aggregated into four functions:

void*operator new(size_t size);
void*operator new[](size_t size);
void operator delete (void*ptr);
void operator delete [] (void*ptr);

Once you have redefined them (you might want to call them internally malloc/free), you can see the increase or decrease in memory usage due to memory retention and release.Then you can manage your own memory limits within new.

However, this method has not been involved in malloc other memory reserves.


2022-11-28 19:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.