On Thu, 2012-08-23 at 16:21 -0700, Charles Hixson wrote: > Is it possible to detect when a program is using, say, 90% of the memory > that is available, so that I can take steps to reduce usage? I've got a
You could use getrusage. I don't think it's currently bound, but it would be easy enough to add. Note that this will only tell you how much memory a program is using, not how much memory *all* programs are using. To get the total system memory you could just parse /proc/meminfo. You could also use this to get the amount of memory available. > method that would like to use probably more memory than is available, > but which can (if it could tell) save stuff to files to free memory it > isn't using at the moment. Garbage collection, isn't quite the same Sounds a lot like swapping to disk, which the OS will do for you... > thing. I don't want the stuff to be garbage collected until after I've > saved it's current state, but to know when to do that, I need to know > how much memory is currently free. > > I suppose that I could set an arbitrary limit on the number of various > things I allow before compacting, but that's a bit ... arbitrary. And > doesn't adapt to different machines without recompiling. > _______________________________________________ vala-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/vala-list
