[SDL] PNG file loading limit problem

David Allen allend03 at optusnet.com.au
Wed Feb 21 04:25:55 PST 2007


Tomas Carnecky <tom <at> dbservice.com> writes:

> 
> clemens kirchgatterer wrote:
> > On 2/21/07, David Allen <allend03 <at> optusnet.com.au> wrote:
> >> I have a project which uses SDL_image/libPNG to load 1063 png files. This
> >> works ok under windows but fails under linux. I know I have enough memory 
to
> >> load all the png files and that all the images display ok on windows and
> >> linux. Linux will load only 1016 files. When trying to load png # 1017 it
> >> reports that the file type is unknown. If I reduce the size of the files 
it
>  >
> > sounds like a file descriptor limit. maybe your program or SDL_image
> > leaks the filedescriptors?
> > 
> 
> $ ulimit -a
> 
> and more specifically
> 
> $ ulimit -n
> 
> will show you how many files you can have open at a time. I have three 
> linux systems, two show 1024, one 4096. 1024 seems to be default, though 
> it's configurable, but you have to have the appropriate permissions 
> (root). I have no idea how to set the limit globally at startup other 
> than editing the kernel headers and recompiling the kernel.
> 
> tom
> 

Thanks guys. This was the clue that solved the problem. I was using:

resource = SDL_RWFromFile(file, "r");
temp_surface = IMG_Load_RW (resource, 0);
...
SDL_FreeRW(resource);

Ive changed to: 

resource = SDL_RWFromFile(file, "r");
temp_surface = IMG_Load_RW (resource, 1);
...


The free function was not releasing the file handle.



More information about the SDL mailing list