# SystemException[“MemoryAllocationFailure”] returned evaluating DiscretizeRegion@RegionIntersection between two spheres

Trying the code in this answer, in particular the RegionIntersection part, I get, on v10.4.1 under windows, a

Throw::sysexc: Uncaught SystemException returned to top level. Can be caught with Catch[\[Ellipsis], _SystemException]
Out[] = SystemException["MemoryAllocationFailure"]


In particular, this error is given evaluating the following simple code (WARNING: this may hang your system for a while):

DiscretizeRegion@RegionIntersection[
Sphere[{0, 0, 0}, 1],
Sphere[{1, 0, 0}, .5]
]


Can someone replicate this (thus making it most probably a bug of the last versions of MMA), or is it just me?

• Don't use floating points DiscretizeRegion@ RegionIntersection[Sphere[{0, 0, 0}, 1], Sphere[{1, 0, 0}, 1/2]] – Feyre Sep 4 '16 at 16:07
• It works for me (MMA 11, Ubuntu 15.10) the first time I run it. The second time, I get Uncaught SystemException returned to top level. Can be caught with Catch[\[Ellipsis], _SystemException].. Not using floats works. – anderstood Sep 4 '16 at 16:08
• @Feyre not using floats works. Still, I'm guessing the system should not be so unstable to crash if floating point numbers are used for the radius, right? Can you replicate the error in that case? – glS Sep 4 '16 at 16:09
• @glS I get the error, but also use 10.4, so I guess it's fixed in 11. – Feyre Sep 4 '16 at 16:10
• I get the exception on both V11.0.0 and V10.4 under Linux Mint 17.3 (each time I run the code) – mikado Sep 4 '16 at 18:07

On a hunch I found Specifying MaxCellMeasure helps.

DiscretizeRegion[
RegionIntersection[Sphere[{0, 0, 0}, 1], Sphere[{1, 0, 0}, .5]]
, MaxCellMeasure -> 0.1]


As it is a 2d plot, you need very small MaxCellMeasure for a neat circle:

MaxCellMeasure -> 0.00001


• This is a good workaround, thanks. I think we can say that this is a bug anyway, so I'll also report it to the wolfram support. – glS Sep 4 '16 at 22:18
• @glS Aye, tis that. – Feyre Sep 5 '16 at 8:40