     
     // Now lest allocate all the image memory on the GPU, so we can use it later. If we have made our numbers correctly
     // in the previous section this should leave enough space for the textures.
-    size_t num_bytes_img = geo.nVoxelX*geo.nVoxelY*geoArray[0].nVoxelZ* sizeof(float);
-    
+    size_t num_bytes_img = (size_t)geo.nVoxelX*(size_t)geo.nVoxelY*(size_t)geoArray[0].nVoxelZ* sizeof(float);
+    
+    
+        
+//     mexPrintf("num_bytes_img: %zu \n ",num_bytes_img);
+//     mexPrintf("geo.nVoxelX: %zu \n ", (size_t)geo.nVoxelX);
+//     mexPrintf("geo.nVoxelY: %zu \n ", (size_t)geo.nVoxelY);
+//     mexPrintf("geo.nVoxelz: %zu \n ", (size_t)geoArray[0].nVoxelZ);
+//     mexPrintf("split_image: %u \n ",split_image);
+//     
+//     return 1 ;
     
     float** dimage=(float**)malloc(deviceCount*sizeof(float*));
     for (dev = 0; dev < deviceCount; dev++){

        
        mem_free=mem_GPU_global-(mem_image/deviceCount)/(*split_image); // NOTE: There is some rounding error, but its in the order of bytes, and we have 5% of GPU free jsut in case. We are safe
        
        *split_projections=(mem_proj*nalpha+mem_free-1)/mem_free;
        
// //         unsigned int total_slices_proj=(geo.nVoxelZ+VOXELS_PER_THREAD-1)/VOXELS_PER_THREAD;

        
        *split_projections=(mem_proj*nalpha+mem_free-1)/mem_free;
    }
    // They do not fit in memory. We need to split both projections and images. Its OK, we'll survive.
    else
    {
