![]() |
How to get volume of a free RAM?
Hello,
I want to know how many RAM on N900 is free before I start some operation in my Qt app. I thinked that I`ll can get this info from HAL, but in list of devices /org/freedesktop/Hal/devices/ I don`t found something about RAM. EDIT: So, I found some solution. I read from file /proc/meminfo lines with memory usage. Maybe does anyone know a more elegant solution? |
Re: How to get volume of a free RAM?
Why do you want to know this?
And, more specifically, are you looking for how much memory you would be able to allocate with one call to malloc or how much you see marked as "Free" using the command top? The file /proc/meminfo contains a lot of information but be careful with what you actually ask for. |
Re: How to get volume of a free RAM?
what do you need the info for?
there is a possibility that you don't have to worry about free ram at all. |
Re: How to get volume of a free RAM?
There's probably a "UNIX Way" but /usr/include/osso-mem.h (part of the libosso library that is standard on Maemo) has functions to do what you want.
|
Re: How to get volume of a free RAM?
I need this because my app in some time run function, which needs much free memory and I want prevent it uses if free RAM is not enought.
|
Re: How to get volume of a free RAM?
doesn't os free up ram if needed? or was this only in OS2008?
|
Re: How to get volume of a free RAM?
Linux allocates RAM optimistically, that is it will appear to allocate blocks with new and malloc but not actually allocate them until they are used, and may use swap then if it has overallocated beyond its means.
|
Re: How to get volume of a free RAM?
Quote:
The N900 has ~1GByte of "memory" with 256MByte as actual RAM capsules and the rest as swap on disk. The swap on my phone is typically not used at all, even after several days of usage, so it's possible to say that ~740MByte of memory is "free" no matter what. So, if your function needs, say, 100MByte and 235MByte of capsule RAM is allocated, you have 20MByte of capsule RAM and 740MByte of swap left. Would you say that this is enough to run your function or do you need to have 100MByte of capsule RAM available? |
All times are GMT. The time now is 20:19. |
vBulletin® Version 3.8.8