PNG file loading limit problem

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
still fails loading file 1017. If I reduce the number of files loaded below
1000 the linux version will work correctly. Is there some configuration limit
in linux builds that might cause limit in file loads?

sounds like a file descriptor limit. maybe your program or SDL_image
leaks the filedescriptors?

clemensOn 2/21/07, David Allen 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
still fails loading file 1017. If I reduce the number of files loaded below
1000 the linux version will work correctly. Is there some configuration limit
in linux builds that might cause limit in file loads?

clemens kirchgatterer wrote:> On 2/21/07, David Allen 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

Tomas Carnecky <tom dbservice.com> writes:

clemens kirchgatterer 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.> > On 2/21/07, David Allen <allend03 optusnet.com.au> wrote: