Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rate Thread Display Modes
Old 11-17-2003, 11:54 AM   #1
fragerybou
Triple-A Player
 
Join Date: Sep 2002
Posts: 95
fink/prebinding memory leak?

The past few times I've used fink, I noticed that the hard drive starts churning after the install is done. I checked out top/activity monitor, and it says that the update/fix prebinding process is going. I can live with that. However, once the install is complete, I end up with about 6mb of free RAM, as opposed to over 256MB free before. I know the amount of free ram isn't quite as important in OS X's memory management view, but when I add up the totals listed for all processes, it adds up to maybe 160MB, rather than 420MB of real memory usage. Yet free memory is still extremely small.

Is anyone else experiencing this? Does anyone know of a way to reclaim the memory without rebooting?

AlBook G4 1.25ghz with 512mb of ram, 10.3.1 (7C107). Fink is at 0.62, package manager is 0.16.2.
fragerybou is offline   Reply With Quote
Old 11-17-2003, 12:25 PM   #2
macmath
MVP
 
Join Date: Mar 2002
Location: Elsewhere
Posts: 1,497
If you compile from source, fink installations do require a lot of memory, I'd agree with that from my experiences.

I used to want to reclaim that memory, too, but others here have explained to me that the OS is working correctly, keeping in memory things that it feels it might need again soon. If it needs that memory for something else, it will reclaim that memory itself and use it for that something else.

That having been said, executing in Terminal:

sudo du -sx

will reclaim the free memory space. After a fink installation, it is unlikely that you'll be needing that memory information for gcc, etc, so reclaiming the memory is not going to circumvent your OS's efficiencies too much. In your day-to-day computing, reclaiming that memory might make your OS have to go get some things from the disk again that it would have been holding in RAM.
macmath is offline   Reply With Quote
Old 11-17-2003, 01:09 PM   #3
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
you should give that du a sufficient target; as it is stated above, the default dir to size is implicitly `.' and if your cwd doesn't contain a large number of files, it won't achieve the "sustained disk access" required to return inactive memory to the free list.

this should be an adequate 'inactive memory squisher' for any shell...
Code:
sh -c 'du -sx /System/ &> /dev/null'
mervTormel is offline   Reply With Quote
Old 11-17-2003, 02:05 PM   #4
macmath
MVP
 
Join Date: Mar 2002
Location: Elsewhere
Posts: 1,497
Quote:
Originally posted by mervTormel
you should give that du a sufficient target; as it is stated above, the default dir to size is implicitly `.' and if your cwd doesn't contain a large number of files, it won't achieve the "sustained disk access" required to return inactive memory to the free list.

this should be an adequate 'inactive memory squisher' for any shell...
Code:
sh -c 'du -sx /System/ &> /dev/null'

I didn't know that. Thanks the information and for fixing my suggestion so that it would work as advertised.

If an application really did have a memory leak, would this jar the memory loose. Or, being a memory leak, would the OS assume that this application still owned that memory?
macmath is offline   Reply With Quote
Old 11-17-2003, 02:35 PM   #5
fragerybou
Triple-A Player
 
Join Date: Sep 2002
Posts: 95
Quote:
Originally posted by macmath
If an application really did have a memory leak, would this jar the memory loose. Or, being a memory leak, would the OS assume that this application still owned that memory?

This is what I was afraid of, because in the activity monitor, there is a large portion of allocated "active" ram, which isn't owned by any processes at all. Fortunately, using the command posted by macmath and merv, that ram came back instantly.

Does anyone know of a way to configure fink to automatically run this after installing something?
fragerybou is offline   Reply With Quote
Old 11-17-2003, 02:47 PM   #6
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
Quote:
Originally posted by fragerybou
...there is a large portion of allocated "active" ram, which isn't owned by any processes at all...

dubious. how do you know this or how did you determine this?
mervTormel is offline   Reply With Quote
Old 11-17-2003, 03:55 PM   #7
macmath
MVP
 
Join Date: Mar 2002
Location: Elsewhere
Posts: 1,497
Quote:
Originally posted by fragerybou
Fortunately, using the command posted by macmath and merv, that ram came back instantly.

Does anyone know of a way to configure fink to automatically run this after installing something?

I'm not certain, but I think that the fact that it was released to you by mervTormel's command means that it was never locked up anyway and was available all along for release by the OS to another application that needed it.

While (from our OS x, x<=9 days) it psychologically makes you and I feel better to see a lot of free RAM, it really isn't any better [as long as what is not really in use will be released when needed].
macmath is offline   Reply With Quote
Old 11-17-2003, 06:31 PM   #8
fragerybou
Triple-A Player
 
Join Date: Sep 2002
Posts: 95
Quote:
Originally posted by mervTormel
dubious. how do you know this or how did you determine this?

I added up all of the ram listed (all processes) in the activity monitor, and compared it with the total. But that's probably flawed, now isn't it?

I take it neither of you know how to modify fink to run du at the end?
fragerybou is offline   Reply With Quote
Old 11-17-2003, 07:22 PM   #9
macmath
MVP
 
Join Date: Mar 2002
Location: Elsewhere
Posts: 1,497
I don't know how one would do that. I have a fragment of an idea surrounding writing scripts which would ask fink to do its thing and then call 'du', but to really make it robust would take *me* a lot of time. What if Fink did not have any base files to compile and install when you said 'fink selfupdate'? What if when you said 'fink update-all', the curl command failed and could not get something. Those kind of things.

You could just put an alias to mervTormel's command in your .cshrc or .bashrc file. Call it 'freemem' and just enter 'freemem' and hit return after each fink compile.
macmath is offline   Reply With Quote
Old 11-17-2003, 07:30 PM   #10
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
hmm, i don't think you want to modify the fink command; it wouldn't survive updates.

you might want to squish inactive memory when a certain highwater mark is reached.

so, something in a cron job that checks the free-mem value and fires the du when a minimum is exceeded?

for starters:
Code:
$ vm_stat | grep free:                   
Pages free:                   138982.
mervTormel is offline   Reply With Quote
Old 11-17-2003, 09:28 PM   #11
fragerybou
Triple-A Player
 
Join Date: Sep 2002
Posts: 95
Quote:
Originally posted by mervTormel
hmm, i don't think you want to modify the fink command; it wouldn't survive updates.

you might want to squish inactive memory when a certain highwater mark is reached.

so, something in a cron job that checks the free-mem value and fires the du when a minimum is exceeded?

Thanks, I had thought of doing something like that earlier today, but completely forgot about it. It'd definitely be a lot better than using it just after fink. I'll post the script when I get it working, if any of you want it.
fragerybou is offline   Reply With Quote
Old 11-17-2003, 10:12 PM   #12
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
i toyed with this long ago.
Code:
#!/bin/sh

# file: mflog - trigger memory flushing on hiwater breach

hiwater=12800 # 50MB at 4096 byte pages  

# loop here

freemem=`/usr/bin/vm_stat | /usr/bin/grep free: | /usr/bin/sed 's/[^0-9]//g'`  

[ ${freemem} -lt ${hiwater} ] && echo lt # this is where to implement the du

[ ${freemem} -gt ${hiwater} ] && echo gt

# sleep 45

# end loop
to be efficient, this would get put in a loop with a reasonable sleep period, and launched by cron @reboot
mervTormel is offline   Reply With Quote
Old 11-17-2003, 10:42 PM   #13
fragerybou
Triple-A Player
 
Join Date: Sep 2002
Posts: 95
Thanks for the script merv, mine was basically the same. I used anacron to schedule it every 10 minutes (i think). But again, thanks to both of you for the help.
fragerybou is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 03:00 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.