heap-memory

Why do successive calls to new[] not allocate contiguous memory?

℡╲_俬逩灬. 提交于 2019-12-01 08:37:25
I am using Ubuntu 14.04 64-bit. Here is my C++ code to see how memory is used. int main() { int **ptr; ptr = new int* [2]; cout << &ptr << " -> " << ptr << endl; for (int r = 1; r <= 2; r++) { ptr[r-1] = new int [2 * r]; cout << &ptr[r-1] << " -> " << ptr[r-1] << endl; for (int c = 0; c < 2 * r; c++) { ptr[r-1][c] = r * c; cout << &ptr[r-1][c] << " -> " << ptr[r-1][c] << endl; } } return 0; } Here is my output: 0x7fff09faf018 -> 0x1195010 0x1195010 -> 0x1195030 0x1195030 -> 0 0x1195034 -> 1 0x1195018 -> 0x1195050 0x1195050 -> 0 0x1195054 -> 2 0x1195058 -> 4 0x119505c -> 6 I expected the OS

JVM heap not released

笑着哭i 提交于 2019-12-01 08:33:00
问题 I am new to analyzing memory issues in Java. So pardon me if this question seems naive I have application running with following JVM parameters set: -Xms3072m -Xmx3072m -XX:MaxNewSize=1008m -XX:NewSize=1008m -XX:PermSize=224m -XX:MaxPermSize=224m -XX:SurvivorRatio=6 I am using visualVM to monitor the usage : Here is what I see The problem is, even when the application is not receiving any data for processing, the used memory doesn't go down. When the application is started, the used space

How to get heap usage using jstat?

a 夏天 提交于 2019-12-01 08:31:39
问题 I'm running jstat -gc (from OpenJDK): # jstat -gc 1 S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT 287744.0 290304.0 88368.6 0.0 1469440.0 787186.5 2162176.0 1805969.7 945432.0 923880.4 136576.0 133284.0 268 32.797 21 30.089 62.886 How to read: used heap heap size max heap from this output, just like shown by VisualVM? 回答1: See https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html for general reference. Current heap size would be the sum of all the fields

Error: Could not find or load main class –Xmx1G

£可爱£侵袭症+ 提交于 2019-12-01 06:55:10
This is crazy; has anyone ever seen this before? java –Xmx1G –Xms1G –XX:+UseG1GC -XX:+PerfDisableSharedMem -jar service-1.0-SNAPSHOT.jar Error: Could not find or load main class –Xmx1G I can do this: java -jar service-1.0-SNAPSHOT.jar –Xmx1G –Xms1G –XX:+UseG1GC -XX:+PerfDisableSharedMem but jmap -heap {PID} shows that it's ignoring the options completely. I've tried different variations: java –XX:+UseG1GC -jar service-1.0-SNAPSHOT.jar –Xmx1G –Xms1G -XX:+PerfDisableSharedMem java -Xms1G -Xmx1G -jar service-1.0-SNAPSHOT.jar java –xx:+useg1gc -jar service-1.0-SNAPSHOT.jar java -server –XX::

Why do successive calls to new[] not allocate contiguous memory?

☆樱花仙子☆ 提交于 2019-12-01 06:00:53
问题 I am using Ubuntu 14.04 64-bit. Here is my C++ code to see how memory is used. int main() { int **ptr; ptr = new int* [2]; cout << &ptr << " -> " << ptr << endl; for (int r = 1; r <= 2; r++) { ptr[r-1] = new int [2 * r]; cout << &ptr[r-1] << " -> " << ptr[r-1] << endl; for (int c = 0; c < 2 * r; c++) { ptr[r-1][c] = r * c; cout << &ptr[r-1][c] << " -> " << ptr[r-1][c] << endl; } } return 0; } Here is my output: 0x7fff09faf018 -> 0x1195010 0x1195010 -> 0x1195030 0x1195030 -> 0 0x1195034 -> 1

Initializing numpy array from np.empty

好久不见. 提交于 2019-12-01 05:48:36
How are the sign bits determined when initializing an ndarray from empty memory? >>> np.random.randn(3,3) array([[-0.35557367, -0.0561576 , -1.84722985], [ 0.89342124, -0.50871646, 1.31368413], [ 0.0062188 , 1.62968789, 0.72367089]]) >>> np.empty((3,3)) array([[0.35557367, 0.0561576 , 1.84722985], [0.89342124, 0.50871646, 1.31368413], [0.0062188 , 1.62968789, 0.72367089]]) These float values initialized from empty memory have lost their signs † . Why is that? † Note: this result relies on implementation detail of memory re-use. The question asks what the implementation is doing. numpy.empty

Windows Heap Chunk Header Parsing and Size Calculation

匆匆过客 提交于 2019-12-01 05:46:51
How can I calculate heap chunk size from raw bytes read from memory. I tried below thing. 0:001> !heap Index Address Name Debugging options enabled 1: 00500000 2: 00280000 3: 008f0000 4: 00ab0000 5: 00cc0000 0:001> !heap -a 00500000 .. .. Heap entries for Segment00 in Heap 00500000 address: psize . size flags state (requested size) 00500000: 00000 . 00588 [101] - busy (587) 00500588: 00588 . 00240 [101] - busy (23f) 005007c8: 00240 . 00020 [101] - busy (18) 005007e8: 00020 . 00ca0 [101] - busy (c94) .. .. !heap -a 00500000 shows that size of first chunk is 588 bytes. If we dump the chunk

What does calling bitmap.recycle() on API 11+ do?

倖福魔咒の 提交于 2019-12-01 05:32:51
I know that before API 10 of Android, it was important to call recycle() for Bitmap s that aren't used anymore, since the actual raw data is stored in the native memory. However, as of API 11, Bitmap s are stored in the heap, so my question is: Is it still needed to call recycle() on Bitmap s if the API is large enough (at least 11)? What does it do if I call it on such API? s0nicYouth Official documentation tells that recycle() now is an advanced call so if you want to free your bitmap you can just write something like bitmap = null and GC will take care of everything else. 来源: https:/

Value types in object stored in heap as well?

故事扮演 提交于 2019-12-01 04:45:39
I can imagine this question has been asked thousands of times, but I didn't have much luck in finding the answer, plus this is more out of curiosity than need. Digging into the nuts and bolts of C#, I was wondering since objects are stored in the heap, are the value types within the objects stored in the heap as well or are they placed in the stack? Reed Copsey They are stored in the heap, inside of the memory allocated for the reference type. In addition, value types are often stored in places other than "the stack" . However, the CLI spec does not specify where the memory pool that stores

What does calling bitmap.recycle() on API 11+ do?

末鹿安然 提交于 2019-12-01 03:57:13
问题 I know that before API 10 of Android, it was important to call recycle() for Bitmap s that aren't used anymore, since the actual raw data is stored in the native memory. However, as of API 11, Bitmap s are stored in the heap, so my question is: Is it still needed to call recycle() on Bitmap s if the API is large enough (at least 11)? What does it do if I call it on such API? 回答1: Official documentation tells that recycle() now is an advanced call so if you want to free your bitmap you can