|
From: Konstantin S. <kon...@gm...> - 2009-10-14 11:30:09
|
On Tue, Oct 13, 2009 at 11:17 PM, Konstantin Serebryany < kon...@gm...> wrote: > On Tue, Oct 13, 2009 at 5:54 PM, John Reiser <jr...@bi...> wrote: > > > > > I need to know how much memory is taken by a valgrind process from > > > inside that process. And I need it to be fast. > > > > How fast? > > > > > One option is to read /proc/self/status and extract the VmSize field. > > > Slow, bad. > > > > Doing a pread(,,,0) and parsing the result via strstr+atoi should take > > about 1 microsecond. > > Hm. Perhaps. > I did not think about opening this file for the duration of the run... :) > I need to check the occupied memory very often so that the tool can > react accordingly when the memory is close to its limit. > pread+strstr+atoi might be fast enough. Need to check... > Valgrind does not have pread(). lseek+read+strstr+strtol is a bit too slow for me, so I have to call it less frequently than I would like to. Any idea how to get VmSize inside valgrind w/o reading /proc/self/status? --kcc > > > > > Open /proc/self/status once at the beginning, > > and keep it open for the zillions of calls you'll be making. > > Or does pread fail for files in /proc? > > > > > Another option is to keep track of valgrind's VG(malloc) and users's > > > malloc, etc. Easy to loose something, bad. > > > > > > If you do not trust valgrind internal code then why run it at all? > > Is there such functionality in valgrind core already? > I need to get the number very close to the one in /proc/self/status:VmSize > > > Thanks! > --kcc > > > > -- > > > > > ------------------------------------------------------------------------------ > > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > > is the only developer event you need to attend this year. Jumpstart your > > developing skills, take BlackBerry mobile applications to market and stay > > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > > http://p.sf.net/sfu/devconference > > _______________________________________________ > > Valgrind-developers mailing list > > Val...@li... > > https://lists.sourceforge.net/lists/listinfo/valgrind-developers > |