我在Windows 7 64位计算机上运行使用swing制作的图形化Java应用程序。
我的应用程序是一个可运行的jar文件,我使用以下命令从命令提示符启动:
C:\path\to\jre\java.exe -jar myProg.jar
我的问题是,当我使用JRE8 32位而不使用JRE7 32位或JRE8 64位时,我会遇到巨大的性能问题。
请注意,应用程序使用相同的jar文件运行;唯一的区别是它由不同的JRE运行。
我尝试了不同的JRE8版本,问题仍然存在......
当我使用" -verbose"时比较两个输出参数,我看到我用文本获得超过1500个输出:' [从共享对象文件中加载xxxxxx]'对于JRE7而JRE8则没有 梅比可能会以某种方式联系起来吗?
有没有人知道问题可能是什么?
以下是JRE7的一些输出
[Loaded MainFrame.MainFrame$XtrFileFilter from rsrc:./]
[Loaded java.awt.event.HierarchyListener from shared objects file]
[Loaded java.lang.InterruptedException from shared objects file]
[Loaded java.io.FileWriter from shared objects file]
[Loaded javax.swing.CellEditor from shared objects file]
[Loaded javax.swing.table.TableCellEditor from shared objects file]
[Loaded java.awt.image.RenderedImage from shared objects file]
[Loaded java.awt.image.WritableRenderedImage from shared objects file]
[Loaded java.awt.image.BufferedImage from shared objects file]
[Loaded sun.awt.util.IdentityArrayList from c:\Program Files (x86)\Java\jdk1.7.0_45\jre\lib\rt.jar]
[Loaded java.awt.Window$Type from c:\Program Files (x86)\Java\jdk1.7.0_45\jre\lib\rt.jar]
[Loaded java.util.concurrent.atomic.AtomicBoolean from shared objects file]
[Loaded sun.awt.AWTAccessor$WindowAccessor from c:\Program Files (x86)\Java\jdk1.7.0_45\jre\lib\rt.jar]
[Loaded java.awt.Window$1 from c:\Program Files (x86)\Java\jdk1.7.0_45\jre\lib\rt.jar]
[Loaded sun.awt.AWTAccessor$FrameAccessor from c:\Program Files (x86)\Java\jdk1.7.0_45\jre\lib\rt.jar]
[Loaded java.awt.Frame$1 from c:\Program Files (x86)\Java\jdk1.7.0_45\jre\lib\rt.jar]
[Loaded java.awt.ComponentOrientation from shared objects file]
[Loaded java.awt.Component$3 from c:\Program Files (x86)\Java\jdk1.7.0_45\jre\lib\rt.jar]
[Loaded javax.swing.ImageIcon from shared objects file]
[Loaded MainFrame.Simulation.Simulation from rsrc:./]
[Loaded MainFrame.Optimization.Optimization from rsrc:./]
[Loaded MainFrame.Convergence.Convergence from rsrc:./]
[Loaded java.awt.event.WindowEvent from shared objects file]
[Loaded MainFrame.Menu from rsrc:./]
以下是一些JRE8输出
[Loaded MainFrame.MainFrame from rsrc:./]
[Loaded java.util.EventListener from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded java.awt.event.ActionListener from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded javax.swing.Action from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.reflect.NativeMethodAccessorImpl from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.reflect.DelegatingMethodAccessorImpl from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded javax.swing.UIManager from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded javax.swing.UIManager$LookAndFeelInfo from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.awt.OSInfo from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.awt.OSInfo$WindowsVersion from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.awt.OSInfo$1 from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.awt.OSInfo$OSType from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded java.awt.Toolkit from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.awt.AWTAccessor$ToolkitAccessor from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded java.awt.Toolkit$4 from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.awt.AWTAccessor from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded java.awt.Toolkit$5 from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded java.util.ResourceBundle$Control from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
[Loaded sun.util.CoreResourceBundleControl from c:\Program Files (x86)\Java\jre1.8.0_45\lib\rt.jar]
我为JRE7和JRE8运行了一个Xshare:dump,我得到了以下结果:
JRE7:
Loading classes to share ... done.
Rewriting and unlinking classes ... done.
Calculating hash values for String objects .. done.
Calculating fingerprints ... done.
Removing unshareable information ... done.
Moving common symbols to metadata section at 0x3a033570 ... done.
Moving vmSymbols to metadata section at 0x3a1d2170 ... done.
Moving the remaining symbols to metadata section at 0x3a1d3478 ... done.
Moved 44361 symbols, 1703760 bytes.
Moving pre-ordered read-only objects to shared space at 0x38a30000 ... done.
Moving read-only objects to shared space at 0x38e129b0 ... done.
Moving string char arrays to shared space at 0x38e20cd8 ... done.
Moving pre-ordered read-write objects to shared space at 0x39430000 ... done.
Moving read-write objects to shared space at 0x399e8fb0 ... done.
Moving String objects to shared space at 0x39a3e920 ... done.
Read-write space ends at 0x39a7dd28, 6610216 bytes.
Updating references to shared objects ... done.
An error has occurred while processing the shared archive file.
Unable to create shared archive file c:\Program Files (x86)\Java\jdk1.7.0_45\jre\bin\client\classes.jsa.
Error occurred during initialization of VM
Unable to use shared archive.
JRE8:
Allocated shared space: 27394048 bytes at 0x14a00000
Loading classes to share ...
Preload Warning: Cannot find javax/swing/JComponent$2
Preload Warning: Cannot find javax/swing/RepaintManager$1$1
Preload Warning: Cannot find javax/swing/plaf/metal/MetalLookAndFeel$MetalLazyValue
Preload Warning: Cannot find javax/swing/plaf/metal/MetalLookAndFeel$MetalLazyValue$1
Preload Warning: Cannot find javax/swing/text/AbstractDocument$InsertStringResult
Preload Warning: Cannot find sun/awt/windows/WToolkit$3$1
Preload Warning: Cannot find sun/java2d/Disposer$2
Preload Warning: Cannot find sun/java2d/d3d/D3DScreenUpdateManager$1
Preload Warning: Cannot find sun/java2d/d3d/D3DScreenUpdateManager$1$1
Loading classes to share: done.
Rewriting and linking classes ...
Rewriting and linking classes: done
Number of classes 2383
instance classes = 2369
obj array classes = 6
type array classes = 8
Calculating fingerprints ... done.
Removing unshareable information ... done.
Shared Lookup Cache Table Buckets = 4108 bytes
Shared Lookup Cache Table Body = 50352 bytes
ro space: 5650016 [ 47.7% of total] out of 12582912 bytes [44.9% used] at 0x14a00000
rw space: 5396096 [ 45.6% of total] out of 12582912 bytes [42.9% used] at 0x15600000
md space: 753892 [ 6.4% of total] out of 2097152 bytes [35.9% used] at 0x16200000
mc space: 34032 [ 0.3% of total] out of 131072 bytes [26.0% used] at 0x16400000
total : 11834036 [100.0% of total] out of 27394048 bytes [43.2% used]
答案 0 :(得分:2)
您安装的Shared Class Data存档可能已丢失或损坏。
您可以按照“Regenerating the Shared Archive”
下的文档中的建议进行尝试要重新生成存档,请以管理员身份登录;在联网情况下,登录到与Java SE安装相同的体系结构的计算机,并确保您有权写入安装目录。然后执行命令
java -Xshare:dump
生成存档时将打印诊断信息。
请注意,如果失败,您可以强制使用共享数据来获取错误消息(而不是减速),如同一页所述:
手动控制班级数据共享
当条件允许使用时,会自动启用类数据共享功能。以下命令行选项主要用于诊断和调试目的,可能会在将来的版本中更改或删除。
-Xshare:off
- 禁用类数据共享。
-Xshare:on
- 要求启用类数据共享。如果由于各种原因无法启用,请输出错误消息并退出。
-Xshare:auto
- 默认值;尽可能启用类数据共享。
答案 1 :(得分:0)
不确定这是否是您正在寻找的答案,我在Windows 2012服务器上遇到此问题。对我来说唯一的解决方案是卸载java然后重新安装它。