my PC has 2GB memory, Can I write C++ prototype program that run for 2
hour and don't free / delete any memory?
It's a graphics / OpenGL program.
Sure you can write such a program, if it does not allocate any dynamic
memory then it has no need to delete it either.
But I guess you meant a program which is actually allocating something.
Let's see - 2 hours is 7200 seconds. 2GB divided by 7200 seconds makes ca
300000 bytes per second. So if your program allocates new memory lower
than this rate, it should be possible - theoretically. However, this is
not nice to other applications running at the same time.
Note that your OS most probably has a swap file or partition, which
increases the available memory so you should be able to go over 2GB
limit. OTOH, if your process is 32-bit, then it will run out of address
space, depending on the OS only 1 to 3 of the total 4GB address space
might be available to the user data in the process, and part of this is
taken by non-dynamic data structures. Also, when parts of the memory
start swapping out, the performance of the machine degrades.
So what's your goal? You have a contract by which you are paid for the
program immediately when it has run 2 hours without problems? ;-)
Paavo