RE: Optimize causes an error.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> How the heck to I find out how much free memory I have in c?

I am unaware of how to do this using standard 'C/C++' without simply
allocating blocks (in smaller and smaller increments as the allocs fail)
until nothing more can be allocated.  This is probably not what you want.
I think the answer you're looking for is in a function that reports the
amount of RAM installed and/or available to your process - that would be
a platform API (I know of no equivalent in the CRT or C++ Std Lib), so it 
is necessarily OS dependent.

Regarding your original problem with optimization - I don't have a
definitive answer (which would be difficult anyway, because part of
the code is missing - this is not a "self-contained" example) but I do
have a recommendation (based on some "hard won experience") :
1) turn up warnings and pay attention to any that are emitted for this
   section of code.
2) make sure you aren't comparing ints and unsigned ints
I really hope this helps and/or it's something as simple for you as this!

  - Mike


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux