|
From: Nicholas N. <nj...@cs...> - 2008-12-13 11:27:49
|
On Sat, 13 Dec 2008, zhangyan wrote:
> I have used the valgrind for a long time,and recently I am writing a program
> which will allocate a very large block of memory once a time,and The
> valgrind will always report the warning "set address range perms: large
> range <number>".
>
> That's is really annoying.
>
> The version of valgrind which I use is 3.3.0,and I have read the source code
> of memcheck/mc_main.c this file,
>
> that indicate if we allocate a memory more than 100MB once a time,the
> valgrind will report this warning. So I want to know there is any reason why
> 100MB exactly???
The number 100MB isn't particularly significant. The warning is there to
help debug Valrind itself -- at various times the memory size number has
been incorrect, and flagging large allocations catches many of these cases.
So feel free to comment out the relevant line and recompile.
> And I guess the reason why set a threshold is that if I allocate too much
> bytes as a block a time,the valgrind can't trace it exactly,even this block
> of memory will be "definitely lost",the valgrind will report "possibly
> lost".Is it correct???
>
> I made this guess becauase recently I have done a experiement to test
> valgrind's exactness,I allocate a specific number of bytes once a time,and
> the program is like this
>
> #define N 79814486
>
> void foo()
>
> {
>
> char *a=(char*)malloc(N);
>
> }
>
> int main()
>
> {
>
> foo();
>
> return 0;
>
> }
>
> And I thought the valgrind will report the error message of "definitely
> lost",but when the N is more than or equal to 79814486,the valgrind will
> report the error message of "possbily lost" instead of "definitely lost".
>
> So I guess the reason why the developer set the 100MB is because if we
> allocate too big
No, the two things are unrelated. Whether you get "definitely" or
"possibly" lost is largely a matter of luck -- if there are any values that
could conceivably point into the middle of a block, it's considered
"possibly" lost. (See the manual for more explanation.) As you make blocks
bigger, this becomes more likely.
Nick
|