heap-memory

How is heap and stack memories managed, implemented, allocated?

倖福魔咒の 提交于 2019-11-27 08:43:18
In C/C++ we can store variables, functions, member functions, instances of a class either on a stack or a heap. How is each implemented? How is it managed (high level)? Does gcc preallocates a chunk of memory to be used for the stack and heap, and then doles out on request? Is original memory coming from RAM? Can a function be allocated on the heap instead of a stack? Clarification I am really asking about implementation and management of heap and stack memories. After reading referenced question, I didn't find anything that addresses that... thanks for the link Modern operating systems do not

How to view the current heap size that an application is using?

☆樱花仙子☆ 提交于 2019-11-27 06:33:24
I think I increased my heap size to 1 GB in NetBeans since I changed the config to look like this: netbeans_default_options="-J-Xmx1g ...... After I restarted NetBeans, can I be sure that my app is given 1 GB now? Is there a way to verify this? Use this code: // Get current size of heap in bytes long heapSize = Runtime.getRuntime().totalMemory(); // Get maximum size of heap in bytes. The heap cannot grow beyond this size.// Any attempt will result in an OutOfMemoryException. long heapMaxSize = Runtime.getRuntime().maxMemory(); // Get amount of free memory within the heap in bytes. This size

How do I increase Groovy's JVM Heap Size?

蓝咒 提交于 2019-11-27 05:58:47
问题 Some sources on the web claims that I should be able to give the -Xmx param to groovy but that just gives me java.io.FileNotFoundException when it can't find the -Xmx file. Other sources tell me to set some variable named JAVA_OPTS but how do I do that? And how do I know if it worked? 回答1: $ export JAVA_OPTS="$JAVA_OPTS -Xmx64M" $ groovy 回答2: UPDATED: Go to your Groovy home folder and go into the bin directory. In startGroovy.bat, you can set it from 128MB to 512MB like this: ... @rem set

Young , Tenured and Perm generation

对着背影说爱祢 提交于 2019-11-27 05:00:29
问题 I'm confused with Heap,Young,Tenured and Perm generation. Could anyone please explain? 回答1: The Java garbage collector is referred to as a Generational Garbage Collector . Objects in an application live for varying lengths of time depending on where they are created and how they are used. The key insight here is that using different garbage collection strategies for short lived and long lived objects allows the GC to be optimised specifically for each case. Loosely speaking, as objects

Error Java Heap size in Android Studio 1.3.1

余生颓废 提交于 2019-11-27 03:34:14
问题 I recently updated Android Studio from 1.2 to 1.3.1 . After updating Gradle Sync failed message is started showing up to increase Java heap size. Following is the screenshot of error. TIA 回答1: Go to your Android Studio Folder Where it is installed. There is File stduio.exe and studio64.exe with file type of VMOPTIONS , open it in notepad you will see Something like this: -Xms512m -Xmx1280m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=225m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB

How to configure heap size when starting a Spring Boot application with embedded tomcat?

喜夏-厌秋 提交于 2019-11-27 01:15:31
问题 I am trying to deploy a Spring Boot powered web app to production. The app is built with Spring Boot 1.0.1 and has the default Tomcat 7 embedded as application server. I want to allocate larger memory to the app when start the app with java -jar myapp.jar command line. Should I use JVM parameter such as -Xms -Xmx or use environment variable such as JAVA_OPTS ? I have tried to look for the answer in documentation or google it, but did not get answer. Can anyone give some hints? 回答1: Just use

Set default heap size in Windows [duplicate]

馋奶兔 提交于 2019-11-27 00:30:21
问题 This question already has answers here : how to increase java heap memory permanently? (4 answers) Closed 6 years ago . I want to set Java heap size permanently and don't want to run every jar file with options. I use Windows and Java 1.7. 回答1: Setup JAVA_OPTS as a system variable with the following content: JAVA_OPTS="-Xms256m -Xmx512m" After that in a command prompt run the following commands: SET JAVA_OPTS="-Xms256m -Xmx512m" This can be explained as follows: allocate at minimum 256MBs of

How does the JVM ensure that System.identityHashCode() will never change?

一笑奈何 提交于 2019-11-27 00:08:06
Typically the default implementation of Object.hashCode() is some function of the allocated address of the object in memory (though this is not mandated by the JLS ). Given that the VM shunts objects about in memory, why does the value returned by System.identityHashCode() never change during the object's lifetime? If it is a "one-shot" calculation (the object's hashCode is calculated once and stashed in the object header or something), then does that mean it is possible for two objects to have the same identityHashCode (if they happen to be first allocated at the same address in memory)?

Thread '<main>' has overflowed its stack when allocating a large array using Box

混江龙づ霸主 提交于 2019-11-26 23:39:20
问题 I'm implementing combsort. I'd like to create fixed-size array on the stack, but it shows stack overflow . When I change it to be on the heap (Rust by Example says to allocate in the heap we must use Box), it still shows stack overflow . fn new_gap(gap: usize) -> usize { let ngap = ((gap as f64) / 1.3) as usize; if ngap == 9 || ngap == 10 { return 11; } if ngap < 1 { return 1; } return ngap; } fn comb_sort(a: &mut Box<[f64]>) { // previously: [f64] let xlen = a.len(); let mut gap = xlen; let

How to analyze memory using android studio

两盒软妹~` 提交于 2019-11-26 23:21:04
Recently switch to android studio from eclipse. How to check app heap and memory allocation in android studio? In Eclipse we have MAT is there anything in the studio to check heap dump, hprof file? I'll explain it in an easy way with steps: First, you have install MAT ( download ) or use: brew cask install memoryanalyzer In Android Studio open Android Device Monitor or DDMS. Select your process "com.example.etc.." Click Update Heap above the process list. In the right-side panel, select the Heap tab. Click in Cause GC. Click Dump HPROF file above the process list. When we downloaded the file