Reputation: 161
I want to test the performance of different c++ programs, with focus on memory handling. I'm working with Ubuntu on Windows Subsystem for Linux, and my pc has 12GB of RAM; since the amount of RAM is quite big for simple programs, I'm unable to tell the time difference between different memory handling choices. For example, preallocating vs push back elements one by one leads to similar times. I think this is because, while pushing back elements, my pc rarely runs out of adiacent memory and it never needs to copy everything and deal with freelist. Am I wrong?
To solve the problem, I'm wondering if there is a way to limit a c++ program's RAM resources, and run it with just 1 or 2GB of RAM.
Upvotes: 2
Views: 469
Reputation: 3495
The ulimit command can help you.
You can use ulimit -a
to see all set limits.
Then you can modify it, following this guide : setting limits with ulimit.
Upvotes: 1