Linux optimistic malloc: will new always throw when out of memory?

It depends; you can configure the kernel’s overcommit settings using vm.overcommit_memory. Herb Sutter discussed a few years ago how this behavior is actually nonconforming to the C++ standard: “On some operating systems, including specifically Linux, memory allocation always succeeds. Full stop. How can allocation always succeed, even when the requested memory really isn’t available? The … Read more

How do I give Jenkins more heap space when it’s running as a daemon on Ubuntu?

There are two types of OutOfMemoryError messages that you might encounter while a Jenkins job runs: java.lang.OutOfMemoryError: Heap space – this means that you need to increase the amount of heap space allocated to Jenkins when the daemon starts. java.lang.OutOfMemoryError: PermGen space – this means you need to increase the amount of generation space allocated … Read more

Error While Reading Large Excel Files (xlsx) Via Apache POI

Here is an example to read a large xls file using sax parser. public void parseExcel(File file) throws IOException { OPCPackage container; try { container = OPCPackage.open(file.getAbsolutePath()); ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(container); XSSFReader xssfReader = new XSSFReader(container); StylesTable styles = xssfReader.getStylesTable(); XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData(); while (iter.hasNext()) { InputStream stream = iter.next(); processSheet(styles, strings, … Read more

Causing OutOfMemoryError in Frame by Frame Animation in Android

I had the same problem. Android loads all the drawables at once, so animation with many frames causes this error. I ended up creating my own simple sequence animation: public class AnimationsContainer { public int FPS = 30; // animation FPS // single instance procedures private static AnimationsContainer mInstance; private AnimationsContainer() { }; public static … Read more

Parallel.ForEach can cause a “Out Of Memory” exception if working with a enumerable with a large object

The default options for Parallel.ForEach only work well when the task is CPU-bound and scales linearly. When the task is CPU-bound, everything works perfectly. If you have a quad-core and no other processes running, then Parallel.ForEach uses all four processors. If you have a quad-core and some other process on your computer is using one … Read more

Java OutOfMemoryError strange behaviour

To keep things in perspective, consider running this code with -Xmx64m: static long sum; public static void main(String[] args) { System.out.println(“Warming up…”); for (int i = 0; i < 100_000; i++) test(1); System.out.println(“Main call”); test(5_500_000); System.out.println(“Sum: ” + sum); } static void test(int size) { // for (int i = 0; i < 1; i++) … Read more

Suggestions to avoid bitmap Out of Memory error

just use this function to decode…this is perfect solution for your error..because i also getting same error and i got this solution.. public static Bitmap decodeFile(File f,int WIDTH,int HIGHT){ try { //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; … Read more