Re: getrusage() -- negative ru_maxrss?!

From: Maksym Sobolyev <sobomax_at_sippysoft.com>
Date: Wed, 07 Jun 2006 22:18:44 -0700
Looks like you are just overflowing long, which is 32bits on i386. You 
are multiplying size in kilobytes by 4K, in 32 bit math, which as it can 
be easily seen will overflow 2^^31 limit and therefore go negative when 
maxrss is more than 512K.

-Maxim

Mikhail Teterin wrote:
> Hello!
>
> I have a program, which uses getrusage() to report its own performance before 
> exiting.
>
> I noticed recently, that the ru_maxrss field is sometimes reported negative -- 
> I don't think, I ever saw this last year, for example... Is the field 
> considered usable and (semi-)accurate, or did FreeBSD abandon it (as Solaris 
> did)?
>
> I currently print it as:
>
> 	fprintf(..., "... used %ld Kb ...", ... ru.ru_maxrss*getpagesize()/1024... );
>
> What's the right way to do it?
>
> 	-mi
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
>
>   
Received on Thu Jun 08 2006 - 05:50:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:57 UTC