[x264-devel] Re: Memory leak detected using Valgrind
Loren Merritt
lorenm at u.washington.edu
Thu Apr 7 03:59:31 CEST 2005
On Wed, 6 Apr 2005, Bill May wrote:
> I'm trying out valgrind to make sure that there are no major memory
> leaks in my program. I also tried the x264 program directly.
>
> Valgrind first finds over 30000 occurrances of "Use of uninitialized
> value of size 8"
> within x264 - no backtrace.
I don't know what's doing that, and without knowing that I can't say
whether it's important. So yes, we do care.
> At the end, it finds 320K bytes in 20 blocks allocated in
> x264_mb_analyse_load_costs,
> which is the x264_malloc call for p_cost_mv[a->i_qp].
That is intentional.
The buffers last the entire duration of the encode. So the only case where
memory leaks matter is if your application goes on to do other encodes
after x264 finishes. But these are static, so the next invokation of x264
uses the same memory. So I don't want to ever free them. They don't even
need to be cleared: they always get the same value.
I suppose I could make it "static int16_t p_cost_mv[52][32768]", which
needs about 3MB more virtual memory on average, but won't use any more
real memory than the current method.
> 2). It seems that p_cost_mv is never initialized to NULL; is this a good
> idea that will work on all platforms ?
Static variables are always initialized, using 0 if no initializer is
specified. And 0 is NULL, even on insane architectures where NULL isn't
bitwise 0.
--Loren Merritt
--
This is the x264-devel mailing-list
To unsubscribe, go to: http://developers.videolan.org/lists.html
More information about the x264-devel
mailing list