Questions about Paint3D's performance pop up often so I decided to create this FAQ. If anything isn't clear or you have any question that hasn't been answered here please reply and I'll add it.
I tried to provide a short and direct answer to every question and for technically inclined users I've followed with a more detailed explanation for each group of questions.
Paint3D runs very slowly, what can I do about it?
If you're running in full screen or a big window try running in a smaller window or enabling subsampling (View/Options/View Mode and Edit Mode/Subsampling) - increase the value until you find a good balance between speed and image quality.
You can also enable Optimize (the option just below Subsampling) - this will disable some features but might improve speed, specially on older hardware.
Why does it get slower when I zoom in?
Because a larger portion of the screen actually "sees" the image. This is normal and it may cease to get slower when every single pixel of the screen "sees" the image.
Isn't the new renderer supposed to be faster than the old one? It seems slower here!
It scales better with volume size and smoothing (a big smoothed image will probably run faster) and memory use will be smaller but it scales worse with resolution (a small image running in full screen with a big resolution will probably run slower). This seemed like a future-proof choice because the new renderer can take advantage of multicore and 64-bit and screen resolutions seem to increase slower than overall computing power.
The new renderer is also more portable, can run on older hardware and has options to increase performance at the cost of image quality.
Why's Paint3D using almost 100% of my CPU while running?
The renderer tries to use as much CPU power as it can to render faster. I might include a way to limit FPS on a future version to address this.
Technical notes about performance on the new renderer
The new renderer is a raycaster that runs 100% in software. It casts a ray for each pixel on the screen and those rays travel until they find a voxel - this is why higher resolutions suffer a performance loss. Subsampling tells the raycaster to render a smaller image and stretch it to fill the window - with 2x2 each rendered pixel is stretched to fill an area of 2x2 screen pixels and so on.
Only rays that intersect the image have to traverse the image, when zoomed out more pixels are unused and perfomance gets better.
In addition, rays that collide faster have to travel less and render faster than rays that have to travel more. That's why an empty image is generally slower to render than a full one. Using the first person camera is also faster because the camera is nearer to the voxels and the rays travel less.
A positive side-effect of raycasting is that only voxels that are visible are actually rendered and that makes it scale better with volume size than using a traditional polygon approach. Smoothing is only computed for visible solid voxels and is considerably faster than on the old renderer.
Why does Paint3D hang when running some scripts?
Scripts are slow due to the interpreted nature of Python and Paint3D may stop responding while running them, specially on big images - this does not mean the program has crashed (altough it can crash due to poorly written scripts), it may just take some time to resume normal execution. You can make scripts execute faster by compiling your code to a .NET dll and using the script to call a function on the dll.
A "Paint3D ran out of memory and must close." message popped up, why?
You're probably working with a bigger volume than .NET or your OS can handle, try working with smaller volumes. 64-bit OS's can handle bigger volumes than 32-bit ones so you might want to consider upgrading your OS. Even on 64-bit OS's the .NET Framework imposes a limit of 1024x1024x512 (or any other size that has the same product).
Lowering your undo limit or even disabling undo completely might help (View/Options/General/Undo Limit). If you're just viewing (as opposed to editing) a very large image you may want to set your default tool (View/Options/General/Default Tool) to None and restart the program.
When this crash happens Paint3D can try to save your work but it may fail due to lack of memory. There's no way to "fix" this.
A "System.OutOfMemoryException" popped up, why?
That happens because sometimes there`s no memory left to pop up the message above and try to save your work. Unfortunately there is nothing that can be done about this. See the question above to learn what you can do to avoid this problem.
Sometimes Paint3D slows down and I can hear my hard drive hard at work, why?
This happens when your OS starts paging intensively to allow programs to use more memory than your physical RAM. It can happen to any program, specially on 64-bit OS's because programs are allowed to use more memory. It might be more noticeable in Paint3D because it deals with volumes - opening a 256x1024x1024 volume is similar to loading 256 pictures of 1 megapixel in memory at the same time.
You can try to reduce memory usage (see above) or get more RAM (consult the maximum supported by your OS before upgrading).
Technical notes about memory usage
32-bit OS's generally have a limit of 4GB of physical RAM and a 2GB limit per process and won't allow a process to use more than that even if physical memory is available. More detailed explanations about limits in Windows can be found here (this link also has a workaround to increase the per process limit to 3GB).
In practice there are further complications because the 2GB limit is "seen" as a contiguous block of memory and even when it has the total free space to allocate an image it may not be able to do so because it's fragmented in small portions - that kind of stuff is controlled by the .NET Framework and there is little I can do to change it. This problem is mitigated by 64-bit OS's because each process has a much larger address space available.
Even on 64-bit OS's the .NET Framework limits arrays to 2GB. Each voxel uses up 4 bytes (32-bit color) so a 1024x1024x512 or equivalent volume hits that limit - that's currently the hard limit for image size in Paint3D. I could split the array to work around this limit but it's so slow at those sizes that I don't think it's worth the trouble, at least for now.
I have a couple of ideas to reduce memory reallocations (specially when showing tool previews - that's why setting the default tool to none is indicated when viewing a large image) but those need further testing.
Wouldn't Paint3D be faster if it used my top-notch graphics card?
Graphics cards are made to render triangles very fast, which gives an advantage to traditional 3D meshes. That said, I still think the new renderer offers more advantages than the old one.
On the other hand I could use GPGPU to speed Paint3D up but that's a massive amount of work and I'm not willing to do it unless GPGPU support is more widespread and less buggy - using CUDA would considerably limit the amount of compatible computers and enormously increase the complexity of the renderer. I might reconsider this one if a better technology comes up.
What else are you planning to do to improve the performance of Paint3D?
The short answer is that performance is currently the main issue of Paint3D and I'm constantly making small improvements to increase it slightly. A huge improvement may eventually happen but not in the near future.
A way to considerably improve performance and memory usage is to stop using a 3D matrix and use a structure that is compressed in memory using RLE or an octree. The RLE approach is *very* fast but too complicated and limiting. The octree approach is what I'd go with if I started coding Paint3D today but it's a lot of work to change it (it would require a complete rewrite of the renderer and lots of small changes to the rest of the code) and it would also make future features harder to implement - it's something I'd like to do eventually but don't hold your breath.

