area515 / Photonic3D

Control software for resin 3D printers
http://photonic3d.com
GNU General Public License v3.0
133 stars 112 forks source link

ZSlicing Geometry Tests Run Out of Memory When Heap is Limited to 1GB #227

Closed jmkao closed 8 years ago

jmkao commented 8 years ago

I currently have the gradle test task set to limit heap to 1GB.

Since commit 24f0bf1f92ea1dc32cc62a608784995b9f9692bc or b0746164659154d77ff3b97359ba19779793de6f in WesGilster, on Windows I'm seeing that two of the tests run out of memory currently:

org.area515.resinprinter.test.FullTestSuite > org.area515.resinprinter.stl.ZSlicingGeometry.testSpecialPoints[
0] FAILED
    java.lang.OutOfMemoryError: Java heap space
        at org.area515.resinprinter.slice.StlFile.readBinaryFile(StlFile.java:318)
        at org.area515.resinprinter.slice.StlFile.load(StlFile.java:408)
        at org.area515.resinprinter.slice.ZSlicer.loadFile(ZSlicer.java:937)
        at org.area515.resinprinter.stl.ZSlicingGeometry.<init>(ZSlicingGeometry.java:39)

org.area515.resinprinter.test.FullTestSuite > org.area515.resinprinter.stl.ZSlicingGeometry.testPointsOnAllSli
ces[0] FAILED
    java.lang.OutOfMemoryError: Java heap space
        at org.area515.resinprinter.slice.StlFile.readBinaryFile(StlFile.java:318)
        at org.area515.resinprinter.slice.StlFile.load(StlFile.java:408)
        at org.area515.resinprinter.slice.ZSlicer.loadFile(ZSlicer.java:937)
        at org.area515.resinprinter.stl.ZSlicingGeometry.<init>(ZSlicingGeometry.java:39)

This may or may not be a problem depending on whether it's intended that whatever STL is being loaded should actually be printable on an RPi or not. If not, I can adjust the test parameters.

WesGilster commented 8 years ago

This is a problem, it's fixed and I've checked it in. These heap issues happen when ASCII files are interpreted as binary files because the face count is interpreted as a binary int from what was designed to be 4 printable ASCII bytes. The smallest binary int you can possibly build from 4 printable ASCII chars is four spaces which ends up being 2.5 gig triangles. Well above the established 1 gig limit.

I alluded to this before in some other bugs, but didn't really describe this in any detail. I describe it in detail because it's understandable that memory issues can be concerning on embedded devices.

The solution I provided isn't permanent, and will be fixed when #226 is fixed.

WesGilster commented 8 years ago

More permanent fix applied and released into production