Failed to allocate 1240308 bytes in function 'OutOfMemoryError'

All example code was initially provided in the first message. When you asked me to use a fixed input, I modified my code accordingly. In the original code, I was capturing image data within the captureImage method using the cameraPreviewService method. I changed this section of the code to use a fixed image file instead. If you review the first message carefully, you will see that the imgUrl variable was being set using data from the cameraPreviewService method. In the latest message, however, imgUrl is being set using an image file from the assets folder, and this data is being processed continuously, just like before. In other words, instead of using data from the cameraPreviewService method, I tried to process a fixed image file from the assets folder continuously. As a result, I received an error message that said ‘Cannot perform Construct on a detached ArrayBuffer.’ I had encountered this error before, and it is usually caused by either an ArrayBuffer error or an out-of-memory error. In my latest attempt, I received an ArrayBuffer-related error. I hope I have explained this clearly enough.