Reply
Thread Tools
Posts: 38 | Thanked: 2 times | Joined on Apr 2010 @ Novosibirsk, Russia
#1
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?

Last edited by Grinchman; 2010-05-21 at 06:26. Reason: Temporary solved
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#2
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.
 

The Following User Says Thank You to Joorin For This Useful Post:
ossipena's Avatar
Posts: 3,159 | Thanked: 2,023 times | Joined on Feb 2008 @ Finland
#3
what do you need the info for?

there is a possibility that you don't have to worry about free ram at all.
__________________
Want to know something?
K.I.S.S. approach:
wiki category:beginners. Browse it through and you'll be much wiser!
If the link doesn't help, just use
Google Custom Search
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#4
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.
 
Posts: 38 | Thanked: 2 times | Joined on Apr 2010 @ Novosibirsk, Russia
#5
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.
 
ossipena's Avatar
Posts: 3,159 | Thanked: 2,023 times | Joined on Feb 2008 @ Finland
#6
doesn't os free up ram if needed? or was this only in OS2008?
__________________
Want to know something?
K.I.S.S. approach:
wiki category:beginners. Browse it through and you'll be much wiser!
If the link doesn't help, just use
Google Custom Search
 
fnordianslip's Avatar
Posts: 670 | Thanked: 359 times | Joined on May 2007
#7
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.
__________________
Class .. : Lame hacker & beardy boffin
Humour . : [#######---] Alignment: Apathetic anarchist
Patience : [####------] Weapon(s): My cat, my code.
Agro ... : |#---------] Relic(s) : N900, MacBookPro, NSLU2, N800, SheevaPlug, Eee-901, Core2-Quad, PS3
"In theory, theory and practice are the same. In practice, they're not."
--
Beware of extras-devel.
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#8
Originally Posted by Grinchman View Post
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.
You still haven't defined "free memory".

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?
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 14:44.