我的Java应用程序通过运行"java -jar j.jar"进程运行另一个Java应用程序.众所周知,J.jar根据给定的数据集使用大量内存,并且通常会获得OutOfMemoryError堆.所以我想在它上面使用-Xmx,这样我就可以分配尽可能多的内存(或接近).我想在系统上获取总内存,然后在-Xmx中指定80-90%.
我的问题有什么解决方案吗?而且,我的解决方案听起来如何?
编辑:我不能减少内存消耗,因为正在使用的内存是Java的内置pack200压缩,我用它来打包一些JAR文件.
I have two different PHP files that both write to the same file. Each PHP script is called by a user action of two different HTML pages. I know it will be possible for the two PHP files to be called, but will both PHP files attempt to write to the file at the same time? If yes, what will happen? Also, it is possible to make one of the PHP fail gracefully (file write will just fail, and the …
为什么以下代码每次输出相同的内存位置?
int x;
for (x = 0; x < 10; x++) {
int y = 10;
printf("%p\n", &y);
}
Run Code Online (Sandbox Code Playgroud)
我认为每次运行for循环时内存位置都应该改变,变量是新的.
我的应用程序是随机暂停(进入onPause方法)然后恢复(进入onResume方法),当我甚至没有触摸屏幕.在logcat中,没有指示导致暂停和恢复的原因.这只发生在Galaxy Tab 7"而不是Motorola Xoom或HTC Legend上.
如何确定暂停的原因?
我使用以下代码调整位图大小:
FileOutputStream out = new FileOutputStream("/sdcard/mods.png");
Bitmap bmp = Bitmap.createScaledBitmap(pict, (int)(pict.getWidth() / totScale),
(int)(pict.getHeight() / totScale), false);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
out.close();
Run Code Online (Sandbox Code Playgroud)
从我正在使用的相机获取位图的代码如下:
mCamera.takePicture(null, null, null, new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
pict = BitmapFactory.decodeByteArray(data, 0, data.length);
}
});
Run Code Online (Sandbox Code Playgroud)
第一张图是我在手机上看到的(在Astro文件管理器中),也是我在画布上绘制应用程序中的位图时的图片.这种情况发生在我测试过的每台设备上(HTC Legend和Galaxy Tab)第二张图片就是我电脑上的样子.什么导致设备上的块?
这是解决我的问题的原因:而不是
pict = BitmapFactory.decodeByteArray(data, 0, data.length);
Run Code Online (Sandbox Code Playgroud)
我替换了
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
pict = BitmapFactory.decodeByteArray(data, 0, data.length, opts);
Run Code Online (Sandbox Code Playgroud)
我正在创建一个java.util.logging.FileHandler
允许循环文件.运行我的应用程序的多个实例时,将为该应用程序的每个实例创建一个新的日志文件.我需要知道应用程序正在使用哪个文件,因为我想将日志文件上传到我的服务器以供进一步查看.如何判断某个FileHandler正在使用哪个文件?
我在横向的LinearLayout中有多个按钮.在较大的设备上,所有按钮文本都以20sp文本大小放在一行上.但是,在20sp文本大小的较小设备上,按钮的文本分为两行.
我如何告诉它使文本大小尽可能大,以便文本保持在一行?
启动时monitor
,它崩溃并在其日志文件中写入以下内容:
org.osgi.framework.BundleException: The bundle "org.eclipse.core.runtime_3.8.0.v20120912-155025 [44]" could not be resolved. Reason: Missing Constraint: Bundle- RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,J2SE-1.3
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
!ENTRY org.eclipse.equinox.common 4 0 2016-03-18 10:50:26.908
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.common_3.6.100.v20120522-1841 [83]" could not be resolved. Reason: Missing Constraint: Bundle- RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176) …
Run Code Online (Sandbox Code Playgroud) 如何使我的ProgessDialog无法关闭,以便用户无法点击后退键,或触摸对话框外的屏幕以将其关闭?
以下代码,在行之间没有任何内容,总是会true
为布尔值生成一个值b
吗?
double d = 0.0;
bool b = (d == 0.0);
Run Code Online (Sandbox Code Playgroud)
我正在使用g ++版本4.8.1.