Discussion:
[Clanlib-devel] [PATCH] Mem leak fixes (against rev 792 0.8 on SVN)
Seth A. Robinson
2006-02-18 04:09:41 UTC
Permalink
Noticed a huge number of mostly GUI related leaks in my program.

To verify, I ran AQTime (memory leak checker) with the GUIWindow example and
it showed around 450KB being leaked in 8000+ leaks (!).

What's in this patch:

* Fixed mem leaks in CL_Directory
* Fixed mem leak in resource_manager_generic.cpp
* Fixed mem leak in menu_node_generic.cpp
* Fixed mem leak in component.cpp by setting delete children to true in
constructors

After doing these changes, it now reports 0 leaks.

Warning: I only tested with the GUIWindow example and my software.

-Seth (mrfun on irc)
Emanuel Greisen
2006-02-18 10:26:13 UTC
Permalink
I have been using valgrind on linux to find my own memory leaks. When
doing this I found the following places in CL_Sprite where valgrind
claims that we are testing on uninitialized data:


169 }
170 if(x > 0) {
171 // Valgrind complains that line[x-1] is not
initialized, could we be beyond the size of 'line', we cannot be before
since x >= 1 ?
172 if((line[x-1] & 0xff000000) != 0)
173 {
174 r+= (line[x-1] & 0x00ff0000) >> 16;
175 g+= (line[x-1] & 0x0000ff00) >> 8;
176 b+= (line[x-1] & 0x000000ff);
177 n++;
178 }
179 }

189 }
190 if(y > 0) {
191 line = (unsigned int *)
(data_bytes+(y-1)*dest_pitch);
192 // Valgrind complains that line[x] is not
initialized, could we be beyond the size of 'line', or maybe before ?
193 if((line[x] & 0xff000000) != 0)
194 {
195 r+= (line[x] & 0x00ff0000) >> 16;
196 g+= (line[x] & 0x0000ff00) >> 8;
197 b+= (line[x] & 0x000000ff);
198 n++;
199 }
200 }
201

Sad enough, I can not figure out this code, so I cannot see if we are
actually working on uninitialized data here, and my sprites seem to work
just fine :-)

./Emanuel
Post by Seth A. Robinson
Noticed a huge number of mostly GUI related leaks in my program.
To verify, I ran AQTime (memory leak checker) with the GUIWindow example and
it showed around 450KB being leaked in 8000+ leaks (!).
* Fixed mem leaks in CL_Directory
* Fixed mem leak in resource_manager_generic.cpp
* Fixed mem leak in menu_node_generic.cpp
* Fixed mem leak in component.cpp by setting delete children to true in
constructors
After doing these changes, it now reports 0 leaks.
Warning: I only tested with the GUIWindow example and my software.
-Seth (mrfun on irc)
Loading...