heap-memory

How does realloc() reallocate the memory?

风流意气都作罢 提交于 2020-02-23 00:37:56
问题 How does realloc() reallocate the memory which was first allocated by malloc() ? I know that you need to use malloc() before you´re able to reallocate the memory, but I don´t understand how that really should work. What if a dynamic-memory object gets decreased in size by realloc() ? Is this respective piece of the object just erased after the call to realloc() ? My Question is: How does the realloc() function reallocate a dynamic-memory object created by malloc() ? Note: I did this Q&A

Is there any advantage in setting Xms and Xmx to the same value?

流过昼夜 提交于 2020-02-21 13:36:34
问题 Usually I set -Xms512m and -Xmx1g so that when JVM starts it allocates 512MB and gradually increases heap to 1GB as necessary. But I see these values set to same say 1g in a dedicated server instance. Is there any advantage for the having both set to the same value? 回答1: Well there are couple of things. Program will start with -Xms value and if the value is lesser it will eventually force GC to occur more frequently Once the program reaches -Xms heap, jvm request OS for additional memory and

Is there any advantage in setting Xms and Xmx to the same value?

折月煮酒 提交于 2020-02-21 13:30:37
问题 Usually I set -Xms512m and -Xmx1g so that when JVM starts it allocates 512MB and gradually increases heap to 1GB as necessary. But I see these values set to same say 1g in a dedicated server instance. Is there any advantage for the having both set to the same value? 回答1: Well there are couple of things. Program will start with -Xms value and if the value is lesser it will eventually force GC to occur more frequently Once the program reaches -Xms heap, jvm request OS for additional memory and

Is there any advantage in setting Xms and Xmx to the same value?

蓝咒 提交于 2020-02-21 13:28:50
问题 Usually I set -Xms512m and -Xmx1g so that when JVM starts it allocates 512MB and gradually increases heap to 1GB as necessary. But I see these values set to same say 1g in a dedicated server instance. Is there any advantage for the having both set to the same value? 回答1: Well there are couple of things. Program will start with -Xms value and if the value is lesser it will eventually force GC to occur more frequently Once the program reaches -Xms heap, jvm request OS for additional memory and

How does the 'delete' operator actually work behind the scenes in C++ in dynamic memory allocation (heap)?

折月煮酒 提交于 2020-02-21 05:49:06
问题 I am not getting how the "delete" operator is actually implemented behind the scenes in C++. For example: class Node{ int i; Node *left,*right; }; int main() { Node* a = new Node; // somehow the object 'a' is initialised with its data members delete a; } What exactly does delete a; do behind the scenes? Like is there any default destructor called upon or what? Also, as a contains left and right pointers, is the object a->left and a->right also deleted? What happens at the core machine level ?

How does the 'delete' operator actually work behind the scenes in C++ in dynamic memory allocation (heap)?

社会主义新天地 提交于 2020-02-21 05:48:45
问题 I am not getting how the "delete" operator is actually implemented behind the scenes in C++. For example: class Node{ int i; Node *left,*right; }; int main() { Node* a = new Node; // somehow the object 'a' is initialised with its data members delete a; } What exactly does delete a; do behind the scenes? Like is there any default destructor called upon or what? Also, as a contains left and right pointers, is the object a->left and a->right also deleted? What happens at the core machine level ?

Java 7 G1GC strange behaviour

旧时模样 提交于 2020-02-04 01:25:15
问题 Recently I have tried to use G1GC from jdk1.7.0-17 in my java processor which is processing a lot of similar messages received from an MQ (about 15-20 req/sec). Every message is processed in the separate thread (about 100 threads in stable state) that serviced by Java limited thread pool. Surprisingly, I detected the strange behaviour - as soon as GC starts the full gc cycle it begins to use significant processing time (up to 100% CPU and even more). I was doing refactoring of the code

Java 7 G1GC strange behaviour

荒凉一梦 提交于 2020-02-04 01:25:12
问题 Recently I have tried to use G1GC from jdk1.7.0-17 in my java processor which is processing a lot of similar messages received from an MQ (about 15-20 req/sec). Every message is processed in the separate thread (about 100 threads in stable state) that serviced by Java limited thread pool. Surprisingly, I detected the strange behaviour - as soon as GC starts the full gc cycle it begins to use significant processing time (up to 100% CPU and even more). I was doing refactoring of the code

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

拜拜、爱过 提交于 2020-01-26 15:12:51
问题 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

G1GC long pause with initial-mark

青春壹個敷衍的年華 提交于 2020-01-23 11:25:27
问题 With j7u5, G1GC "-Xms3200m -Xmx3200m -XX:+UseG1GC -XX:ParallelGCThreads=14 -XX:ConcGCThreads=4 -XX:MaxGCPauseMillis=40 -XX:NewRatio=2 -XX:SurvivorRatio=10 -XX:+PrintGC -XX:+PrintGCDateStamps" for a given performance test, my application hits a long pause after 5-hour run predictably. Except this big one (and only), there are small initial-mark phases. Any suggestions to figure out what is happening to this long pause and how to tune it to avoid such a long pause which affects the latency