winder / Universal-G-Code-Sender

A cross-platform G-Code sender for GRBL, Smoothieware, TinyG and G2core.
http://winder.github.io/ugs_website/
GNU General Public License v3.0
1.86k stars 757 forks source link

Status Freezes in Run and java.lang.OutOfMemoryError #1881

Closed rykellogg closed 1 year ago

rykellogg commented 2 years ago

Version

2.0.11

Hardware / Firmware

GRBL 1.1

What happened

System will run for a minute or so after connection then freezes most functionality and throws error: java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached.

How to reproduce

  1. Open program.
  2. Connect to machine (x-carve 750 in my case)
  3. Send several commands via jog controller or macros.
  4. at some point, status will not return to idle after previous commands and error icon will appear in lower right corner.

Operating System

Windows 11 Home

Anything else

Happens every time. Things I've tried:

May be noteworthy that the ugsplatform.exe file has this issue. The ugsplatform64.exe crashes completely within seconds or a minute after launch. Suspicious I may have a common memory allocation issue here.

rykellogg commented 2 years ago

Updated memory to 1024 per this ticket: https://github.com/winder/Universal-G-Code-Sender/issues/1844 Tried with visualizer turned off per same link. Still no luck and no obvious improvements.

Also tried running in Win 8 compatibility mode with no luck.

rykellogg commented 2 years ago

From system: Processor 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz 2.80 GHz Installed RAM 16.0 GB (15.8 GB usable) System type 64-bit operating system, x64-based processor Edition Windows 11 Home Version 21H2 Installed on ‎4/‎24/‎2022 OS build 22000.652 Experience Windows Feature Experience Pack 1000.22000.652.0

From UGS Product Version: Universal Gcode Platform 20220321 Java: 13.0.1; OpenJDK Server VM 13.0.1+9 Runtime: OpenJDK Runtime Environment 13.0.1+9 System: Windows 10 version 10.0 running on x86; Cp1252; en_US (ugsplatform) User directory: C:\Users\rykel.ugsplatform\2.0.11\dev Cache directory: C:\Users\rykel.ugsplatform\2.0.11\dev\var\cache

breiler commented 2 years ago

Hi, I think the instructions here is wrong for setting the -Xms, this will set the initial heap size. What you probably want is to set the maximum heap size like this: -J-Xmx1024m

rykellogg commented 2 years ago

I performed that change without any improvement. Continuing to sift to see if I have any strange PC configs, and will report back if I find any. Any other ideas?

breiler commented 1 year ago

There is now a 64-bit version available here under the nightly build that you could try: https://github.com/winder/Universal-G-Code-Sender#downloads

rykellogg commented 1 year ago

Thank you. I've got a job for this weekend. I'll try it out.

mrmowgli commented 1 year ago

Ok, this isn't specific to windows. I think it's an issue with the bundled JDK or a system issue. I get the same exact error on Linux, and the linux version comes bundled with 13. I should also point out that my UI is all screwed up as well.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.netbeans.ProxyURLStreamHandlerFactory (file:/home/alewis/apps/ugsplatform-linux/platform/lib/boot.jar) to field java.net.URL.handler
WARNING: Please consider reporting this to the maintainers of org.netbeans.ProxyURLStreamHandlerFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f33e7a0f000, 16384, 0) failed; error='Not enough space' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 16384 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/alewis/apps/ugsplatform-linux/bin/hs_err_pid14714.log

The overall crash info is too big, and I don't know that I can attach the file to this issue? Here's an excerpt the end with some runtime info:

VM Arguments:
jvm_args: -Djdk.home=/home/mowgli/ugsplatform-linux/jdk/jdk-13.0.1+9-jre -Dnetbeans.dirs=/home/mowgli/ugsplatform-linux/etc:/home/mowgli/ugsplatform-linux/extra:/home/mowgli/ugsplatform-linux/ugsplatform:/home/mowgli/ugsplatform-linux/bin:/home/mowgli/ugsplatform-linux/ide:/home/mowgli/ugsplatform-linux/java:/home/mowgli/ugsplatform-linux/platform: -Dnetbeans.home=/home/mowgli/ugsplatform-linux/platform -Xms64m -Xverify:none -Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true -Dnetbeans.indexing.noFileRefresh=true -Dorg.openide.text.big.file.size=20 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/mowgli/.ugsplatform/2.0-SNAPSHOT/dev/var/log/heapdump.hprof 
java_command: org.netbeans.Main --cachedir  --userdir /home/mowgli/.ugsplatform/2.0-SNAPSHOT/dev --branding ugsplatform
java_class_path (initial): /home/mowgli/ugsplatform-linux/platform/lib/boot.jar:/home/mowgli/ugsplatform-linux/platform/lib/org-openide-modules.jar:/home/mowgli/ugsplatform-linux/platform/lib/org-openide-util.jar:/home/mowgli/ugsplatform-linux/platform/lib/org-openide-util-lookup.jar:/home/mowgli/ugsplatform-linux/platform/lib/org-openide-util-ui.jar
Launcher Type: SUN_STANDARD

[Global flags]
     intx CICompilerCount                          = 4                                         {product} {ergonomic}
     uint ConcGCThreads                            = 2                                         {product} {ergonomic}
     uint G1ConcRefinementThreads                  = 8                                         {product} {ergonomic}
   size_t G1HeapRegionSize                         = 1048576                                   {product} {ergonomic}
    uintx GCDrainStackTargetSize                   = 64                                        {product} {ergonomic}
     bool HeapDumpOnOutOfMemoryError               = true                                   {manageable} {command line}
    ccstr HeapDumpPath                             = /home/mowgli/.ugsplatform/2.0-SNAPSHOT/dev/var/log/heapdump.hprof         {manageable} {command line}
   size_t InitialHeapSize                          = 67108864                                  {product} {command line}
   size_t MarkStackSize                            = 4194304                                   {product} {ergonomic}
   size_t MaxHeapSize                              = 8361345024                                {product} {ergonomic}
   size_t MaxNewSize                               = 5016387584                                {product} {ergonomic}
   size_t MinHeapDeltaBytes                        = 1048576                                   {product} {ergonomic}
   size_t MinHeapSize                              = 67108864                                  {product} {command line}
    uintx NonNMethodCodeHeapSize                   = 5836300                                {pd product} {ergonomic}
    uintx NonProfiledCodeHeapSize                  = 122910970                              {pd product} {ergonomic}
    uintx ProfiledCodeHeapSize                     = 122910970                              {pd product} {ergonomic}
    uintx ReservedCodeCacheSize                    = 251658240                              {pd product} {ergonomic}
     bool SegmentedCodeCache                       = true                                      {product} {ergonomic}
   size_t SoftMaxHeapSize                          = 8361345024                             {manageable} {ergonomic}
     bool UseCompressedClassPointers               = true                                 {lp64_product} {ergonomic}
     bool UseCompressedOops                        = true                                 {lp64_product} {ergonomic}
     bool UseG1GC                                  = true                                      {product} {ergonomic}

Logging:
Log output configuration:
 #0: stdout all=warning uptime,level,tags
 #1: stderr all=off uptime,level,tags

Environment Variables:
PATH=/home/mowgli/.local/bin:/home/mowgli/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/mowgli/.local/share/JetBrains/Toolbox/scripts:/home/mowgli/.dotnet/tools:/home/mowgli/.platformio/penv/bin:/home/mowgli/.platformio/penv/bin:/home/mowgli/.local/share/JetBrains/Toolbox/scripts:/home/mowgli/.platformio/penv/bin:/home/mowgli/.platformio/penv/bin
USERNAME=mowgli
SHELL=/bin/bash
DISPLAY=:1

Signal Handlers:
SIGSEGV: [libjvm.so+0xfe1a10], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGBUS: [libjvm.so+0xfe1a10], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGFPE: [libjvm.so+0xfe1a10], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGPIPE: SIG_IGN, sa_mask[0]=00000000000010000000000000000000, sa_flags=SA_RESTART
SIGXFSZ: [libjvm.so+0xc7cd40], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGILL: [libjvm.so+0xfe1a10], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGUSR2: [libjvm.so+0xc7cbe0], sa_mask[0]=00000000000000000000000000000000, sa_flags=SA_RESTART|SA_SIGINFO
SIGHUP: [libjvm.so+0xc7d1e0], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGINT: SIG_IGN, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGTERM: [libjvm.so+0xc7d1e0], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGQUIT: [libjvm.so+0xc7d1e0], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO

---------------  S Y S T E M  ---------------

OS:Fedora release 35 (Thirty Five)
uname:Linux 5.19.10-100.fc35.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Sep 20 15:42:37 UTC 2022 x86_64
libc:glibc 2.34 NPTL 2.34 
rlimit: STACK 8192k, CORE infinity, NPROC 127406, NOFILE 524288, AS infinity, DATA infinity, FSIZE infinity
load average:0.72 0.54 0.24

/proc/meminfo:
MemTotal:       32659952 kB
MemFree:        11483976 kB
MemAvailable:   26259156 kB
Buffers:            5448 kB
Cached:         16051012 kB
SwapCached:            0 kB
Active:          5119228 kB
Inactive:       12262548 kB
Active(anon):       1876 kB
Inactive(anon):  2725120 kB
Active(file):    5117352 kB
Inactive(file):  9537428 kB
Unevictable:     1376532 kB
Mlocked:            5500 kB
SwapTotal:      78785528 kB
SwapFree:       78785528 kB
Zswap:                 0 kB
Zswapped:              0 kB
Dirty:              6496 kB
Writeback:             0 kB
AnonPages:       2701944 kB
Mapped:           580356 kB
Shmem:           1396696 kB
KReclaimable:     590124 kB
Slab:            1391256 kB
SReclaimable:     590124 kB
SUnreclaim:       801132 kB
KernelStack:      463572 kB
PageTables:       150008 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    95115504 kB
Committed_AS:   234885036 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      587536 kB
VmallocChunk:          0 kB
Percpu:            10240 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      364148 kB
DirectMap2M:    14106624 kB
DirectMap1G:    19922944 kB

/proc/sys/kernel/threads-max (system-wide limit on the number of threads):
254812

/proc/sys/vm/max_map_count (maximum number of memory map areas a process may have):
65530

/proc/sys/kernel/pid_max (system-wide limit on number of process identifiers):
4194304

Steal ticks since vm start: 0
Steal ticks percentage since vm start:  0.000

CPU:total 8 (initial active 8) (4 cores per cpu, 2 threads per core) family 6 model 158 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx, fma
CPU Model and flags from /proc/cpuinfo:
model name  : Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities

Memory: 4k page, physical 32659952k(11483976k free), swap 78785528k(78785528k free)

vm_info: OpenJDK 64-Bit Server VM (13.0.1+9) for linux-amd64 JRE (13.0.1+9), built on Oct 26 2019 10:07:46 by "jenkins" with gcc 7.3.1 20180303 (Red Hat 7.3.1-5)

END.

Bundled JDK version: ugsplatform-linux/jdk/jdk-13.0.1+9-jre/

System Java version: /usr/lib/jvm/java-11-openjdk-11.0.16.1.1-1.fc35.x86_64/

mrmowgli commented 1 year ago

hs_err_pid14714.log Here's the full crash file, which should be entertaining.

breiler commented 1 year ago

Thanks for your detailed report @mrmowgli. The problem with windows is that it was using a 32-bit binary. A 32-bit environment only allows 2Gb to be allocated, for which the JVM will default use maximum 1/4th of which will be a bit low when loading a large model.

If I can decipher the log correctly your JVM instance is configured to use ~8Gb max heap space (MaxHeapSize = 8361345024) of a total of 31Gb. So that should be more than enough to run UGS unless you are loading a gigantic Gcode-files or there is some sort of memory leak.

I can see ~4000 references to anon_inode:i915.gem which I guess is graphics card related. Just out of curiosity, can you post your latest log file from: ~/.ugsplatform/2.X/dev/var/log/messages.log

We have had reports of incompatible graphics drivers causing the program too spew errors to the log. (https://groups.google.com/g/universal-gcode-sender/c/pEz1tAZBrH4)

mrmowgli commented 1 year ago

Ah fun times, ok looks like there is at least an actual exception. This is a dual video card laptop, perhaps it is trying to use the Intel driver, but GL is running on the Nvidia card. Hmm. Not sure how to force this from the command line.

        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintToOffscreen(Unknown Source)
        at java.desktop/javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
        at java.desktop/javax.swing.RepaintManager.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent._paintImmediately(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintImmediately(Unknown Source)
        at java.desktop/javax.swing.RepaintManager$4.run(Unknown Source)
INFO [null]: Last record repeated again.
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
INFO [null]: Last record repeated again.
        at com.jogamp.opengl.util.AWTAnimatorImpl$1.run(AWTAnimatorImpl.java:170)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
INFO [null]: Last record repeated again.
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
INFO [null]: Last record repeated again.
        at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: com.jogamp.opengl.GLException: Profile GL4bc is not available on X11GraphicsDevice[type .x11, connection :1, unitID 0, handle 0x7f6965169b50, owner true, ResourceToolkitLock[obj 0x3c3a183f, isOwner true, <35ac425, 658f9d2b>[count 1, qsz 0, owner <AWT-EventQueue-0>]]], but: [GLProfile[GLES1/GLES1.hw], GLProfile[GLES2/GLES3.hw], GLProfile[GL2ES1/GLES1.hw], GLProfile[GL4ES3/GL4.hw], GLProfile[GL2ES2/GL4.hw], GLProfile[GL4/GL4.hw], GLProfile[GLES3/GLES3.hw], GLProfile[GL4/GL4.hw], GLProfile[GL3/GL4.hw], GLProfile[GL2GL3/GL4.hw]]
        at com.jogamp.opengl.GLProfile.get(GLProfile.java:991)
        at jogamp.opengl.GLContextImpl.verifyInstance(GLContextImpl.java:1471)
        at jogamp.opengl.GLContextImpl.setGLFunctionAvailability(GLContextImpl.java:1942)
        at jogamp.opengl.x11.glx.X11GLXContext.createImpl(X11GLXContext.java:395)
        at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:765)
        at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:648)
        at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:586)
        at com.jogamp.opengl.awt.GLJPanel$OffscreenBackend.initialize(GLJPanel.java:1731)
        ... 57 more
INFO [com.willwinder.universalgcodesender.utils.SettingsFactory]: Saving settings.
INFO [org.netbeans.ui.indexing]: Indexing started, time from last indexing 0 ms.
INFO [org.netbeans.ui.indexing]: Indexing finished, indexing took 4 ms.
mrmowgli commented 1 year ago

Ok, so I set Nvidia as the primary driver and everything seems to be ok, no issues with memory or threads. Perhaps this should be mentioned somewhere in the docs?

breiler commented 1 year ago

@mrmowgli excellent, feel free to write a couple of lines how you solved it here: https://github.com/winder/Universal-G-Code-Sender/wiki/Troubleshooting-Overview

breiler commented 1 year ago

Closing as this has been fixed for Windows with the 64-build. Linux will now work better as of 2.0.13 after our update of the JOGL-library.