out-of-memory

java.lang.OutOfMemoryError even though plenty of

做~自己de王妃 提交于 2019-12-17 19:25:04
问题 I am trying to read a 2.5GB txt file into my application. I am running Win7 x64 and have 43GB of mem available (out of 64GB). I tried playing around with -Xmx -XX:MaxParmSize -XX:ParmSize etc. None of these affect the error. What else could I try? This error seems very odd as I certainly have enough heap space available. Exception in thread "main" java.lang.OutOfMemoryError: Requested array size exceeds VM limit at java.util.Arrays.copyOf(Unknown Source) at java.lang.AbstractStringBuilder

Out of memory Error on setImageResource

限于喜欢 提交于 2019-12-17 19:09:40
问题 I'm making a board game, and I'm using a 10x10 GridView for the board. I've made a class ImageAdapter extending BaseAdapter which holds an Integer array of icons (9 patch files), and these are used to display the images for the squares of the board. The icons are stored in the res/drawable folder, are 629X629 and average about 5 KB in size. My ImageAdapter class has the following getView() method, which essentially recycles the same view to save memory: EDIT : (I've included the changeIcon

Java unit testing: how to measure memory footprint for method call

北城以北 提交于 2019-12-17 18:05:51
问题 Assuming I have a class that does some heavy processing, operating with several collections. What I want to do is to make sure that such operation can't lead to out-of-memory or even better I want to set a threshold of how much memory it can use. class MyClass() { public void myMethod() { for(int i=0; i<10000000; i++) { // Allocate some memory, may be several collections } } } class MyClassTest { @Test public void myMethod_makeSureMemoryFootprintIsNotBiggerThanMax() { new MyClass().myMethod()

Horrendous performance & large heap footprint of Java 8 constructor reference?

假如想象 提交于 2019-12-17 17:31:47
问题 I just had a rather unpleasant experience in our production environment, causing OutOfMemoryErrors: heapspace.. I traced the issue to my use of ArrayList::new in a function. To verify that this is actually performing worse than normal creation via a declared constructor ( t -> new ArrayList<>() ), I wrote the following small method: public class TestMain { public static void main(String[] args) { boolean newMethod = false; Map<Integer,List<Integer>> map = new HashMap<>(); int index = 0; while

Understanding php “Out of memory” error

夙愿已清 提交于 2019-12-17 16:33:11
问题 I can find lots of tutorials on how to overcome the out-of-memory error. The solution is: To increase the memory in the php.ini or in the .htaccess - what a surprise... I actually don't understand the error message: Fatal error: Out of memory (allocated 32016932) (tried to allocate 25152 bytes) "Allocated 32016932" , means 32MB have been allocated as in - the PHP script is using 32MB? Tried to allocate 25152 , means that another 25KB were tried to be allocated, but the script failed as the

Problem with downloading multiple files using AsyncTask

£可爱£侵袭症+ 提交于 2019-12-17 16:30:58
问题 I'm using the following script based on the tutorial Android Series: Download files with Progress Dialog to download multiple video files from the internet to the SD card. It displays a progress bar while the download is in progress. public class MyDownload extends Activity { public static final int DIALOG_DOWNLOAD_PROGRESS = 0; private Button startBtn; private ProgressDialog mProgressDialog; private String videoPath = "http://my_site.com/test_videos/"; private String[] fileNames = {"file1

Android Bitmap Limit - Preventing java.lang.OutOfMemory

杀马特。学长 韩版系。学妹 提交于 2019-12-17 15:35:58
问题 I'm currently struggling with an odd behavior of the Android platform -- the Bitmap / Java heap memory limit. Depending on the device, Android limits the app developer to 16, 24, or 32 MiB of Java heap space (or you might find any random value on a rooted phone). This is arguably quite small, but relatively straightforward as I can measure usage with the following API's: Runtime rt = Runtime.getRuntime(); long javaBytes = rt.totalMemory() - rt.freeMemory(); long javaLimit = rt.maxMemory();

Alternative to Get-Content

孤街浪徒 提交于 2019-12-17 14:55:22
问题 I currently have the following line of code. (Get-Content 'file.txt') | ForEach-Object {$_ -replace '"', ''} | Set-Content 'file.txt' This worked when testing, but now I am trying to use it on real data files (13 GB) and this process of using Get-Content is causing Powershell to consume a large amount of RAM and ultimately all of the available RAM on the machine. Is there a better way that I can achieve the same result without the same amount of overhead? Seems I am doing the opposite of best

OutOfMemoryError when seemingly unrelated code block commented out

徘徊边缘 提交于 2019-12-17 14:53:35
问题 Could someone explain why this program throws a OutOfMemoryError when the for loop is commented out? If it is uncommented this runs fine. The exception thrown is: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space public class JavaMemoryPuzzlePolite { private final int dataSize = (int)(Runtime.getRuntime().maxMemory()* 0.6); public void f() { { System.out.println(dataSize); byte[] data = new byte[dataSize]; } /* for(int i = 0; i < 10; i++) { System.out.println("Please be

Force garbage collection of arrays, C#

僤鯓⒐⒋嵵緔 提交于 2019-12-17 12:18:09
问题 I have a problem where a couple 3 dimensional arrays allocate a huge amount of memory and the program sometimes needs to replace them with bigger/smaller ones and throws an OutOfMemoryException. Example: there are 5 allocated 96MB arrays (200x200x200, 12 bytes of data in each entry) and the program needs to replace them with 210x210x210 (111MB). It does it in a manner similar to this: array1 = new Vector3[210,210,210]; Where array1-array5 are the same fields used previously. This should set