I'm having a strange problem with the vil_load_image_resource function. If I try to load a lot of image resources, the function returns successfully only the first 509 times. On the 510th time, nullptr is returned. This simple example recreates my problem:

const char* name = "c:\\path\\to\\myfile.whatever";
vil_image_resource_sptr pResource[510];
for (unsigned int i = 0; i < 510; ++i) {
   pResource[i] = vil_load_image_resource(name);
   if (pResource[i] == nullptr) {
      vcl_cout << "Could not load " << name << " on attempt " << i << vcl_endl;
      return 1;

I have the same problem even with 510 different files. I've built 32-bit binaries from VXL r30525 on Windows XP 64-bit with Visual Studio 2010. With just 509 calls, everything works as expected. Has anyone seen this before? Does someone with knowledge of the internals of VXL have any idea why this might be happening, or where I might look for the bug? Thanks for the help!

:) Michael