5 Replies Latest reply on May 3, 2009 1:28 PM by gareth_cole

    CFImage - Out of memory

      Seeking help and advice ...

      My project has a high traffic load where image uploading is a key feature for our users. We process images that the user has either resized already, or that came directly off a camera in the camera's image format and size.

      I have been running into a issue where I receive the following error message:

      Java heap space null

      and through CF Fussion Reactor have found in logs:

      # An unexpected error has been detected by Java Runtime Environment:
      # java.lang.OutOfMemoryError: requested 23970816 bytes for jbyte in C:\JAVA\jdk6_04\hotspot\src\share\vm\prims\jni.cpp. Out of swap space?
      # Internal Error (allocation.inline.hpp:42), pid=7284, tid=5880
      # Error: jbyte in C:\JAVA\jdk6_04\hotspot\src\share\vm\prims\jni.cpp.

      This occurs at ramdom intervals, the size of the image does not seem matter, and occasionaly the server will restart due to this error.

      In trying to narrow down the source of this error I have used <CFLOG statements all around the steps I implement when uploading an image and further in resizing the image.

      Summary as follows:
      1. User input FORM for image file upload
      2. Process File via <cffile upload -> to a TEMP dir on the server
      3. perform validatation of file type (JPE and JPEG are seen as OCTETSTREAM **another issue but this step allows us to accept OCTETSTREAM mimetypes then check the file extension before proceeding)
      4. If FILE passes then COPY the file to desired location <CFFILE *this step also updates the file name to remove spaces and special characters, as well as creates a unique name (as the copy or move action does not seem to allow for 'MAKEUNIQUE')*
      5. Update the database with the final filename / location
      6. Create object for resize CFC to Check the Image size (call imageresize.cfc)
      7. the image CFC performs a <CFIMAGE to load the image into the cfimage object
      8. Check the height and width to determine if resize as needed
      9. IF resize is true call ImageScaleToFit
      10. Re-Write the image file <cfimage action="write" to overwrite the original file.
      11. DONE - show user a confirm page with resized image.

      Each step above has a custom <CFLOG for START step ???? -> <CFLOG for END step ???? (also meaning SUCCESS of that Step)
      From the log messages I am seeing that the process starts into step 7. and fails with the above messages. the END STEP log is not reached. Loading the image into the CFIMAGE object fails.

      The size of the image does NOT appear to matter, the server simply gets bogged down, probably from a high number of other requests running and other memory loads. Some images will be processed, others fail, and every 12 hours or so, the server will crash with no explaination other than the log messages above.

      Can anyone adivse me on how to better handle this process? Manage memory? dump memory? manage threads? Create a Loop to retry the resize process?

      The server I am using is a new WIN2008 server, CF8 (latest hotfix applied), 4 Gig of RAM. The java Heap is set to 512MB MIN - 1300MB MAX. MaxPermsize=192m

      Thank You
        • 1. Re: CFImage - Out of memory
          jb_aggie Level 1
          So you have applied Adobe's latest CF8Server Hot Fix that deals with the cf8 image tags? This seemed to fix an issue I was having.
          • 2. Re: CFImage - Out of memory
            CF8Hunter Level 1
            That is correct, and to be more specific HOTFIX 71557. This is noted to have fixed an issue with File Locking but does not mention any improvements to how CFIMAGE manages threads or memory.
            • 3. Re: CFImage - Out of memory
              jb_aggie Level 1
              Perhaps there is an issue deeper within the Java code that is behind the CFIMAGE tags that is contributing to your apparent memory problem.

              I wonder if Adobe's CF Architects read these post and could give us some insight into this? In my own experience, using FusionReactor I've notice that the Java Heap continues to build while FusionReactor reports that the CF memory is only between 30% - 50%. I've seen the same Java error in logs and it makes me wonder how CF doesn't seem to report the memory higher when the error in logs reportst that the Java is out of memory.

              Does anyone have comments?

              I hope you/we find a solution.
              • 4. CFImage - Out of memory
                edgriffiths Level 1
                looks like a memory leak



                Error Log for Web Server or Application Server

                Exception in thread "service-j2ee" java.lang.OutOfMemoryError:
                requested 53515 bytes for jbyte in
                Out of swap space?


                The native heap allocation failed and the native heap may be close to exhaustion.

                A native code leak, for example the C or C++ code, continuously requires memory without releasing it to the operating system. There could be indirect causes like an insufficient amount of swap space or another process that is consuming all memory or leaking it.

                For further diagnosis of a native code memory leak, see the Java 5.0 Troubleshooting and Disgnostic Guide at http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf. In the section “Diagnosing Leaks in Native Code.” See the information about tools for different operating systems. The tools include mdb and dbx (runtime trace) for Solaris 9 U3 or later, mtrace , libnjamd for Linux, and windb or userdump for Windows."

                http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=143&threadid= 1305386&enterthread=y
                • 5. Re: CFImage - Out of memory



                  Did you ever find a soluton to this?


                  I applied hot fix 71557 to fix a problem with cfimage locking images. That worked, but now I have a memory leak.

                  I monitor coldfusion's memory usage with SeeFusion, and this gradually increases until I get the same 'out of memory' errors.