Question
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
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
