memory

How to identify memory consumption per thread in a process?

泪湿孤枕 提交于 2021-02-19 09:27:09
问题 A multi-thread process written in C exhausts almost all of system memory. To find out the thread which is consuming most of the memory, I made a core file using gcore [pid] to check the memory usage per threads, but I can't find the way to do that. ps -eLFlm and top command with -H option shows the total memory consumption, but not per thread. Is there any useful tip to solve the problem? OS : Centos6 回答1: A multi-thread process written in C exhausts almost all of system memory. To find out

How to identify memory consumption per thread in a process?

拜拜、爱过 提交于 2021-02-19 09:26:37
问题 A multi-thread process written in C exhausts almost all of system memory. To find out the thread which is consuming most of the memory, I made a core file using gcore [pid] to check the memory usage per threads, but I can't find the way to do that. ps -eLFlm and top command with -H option shows the total memory consumption, but not per thread. Is there any useful tip to solve the problem? OS : Centos6 回答1: A multi-thread process written in C exhausts almost all of system memory. To find out

-XX:OnOutOfMemoryError doesn't work for java.lang.OutOfMemoryError: unable to create new native thread

拥有回忆 提交于 2021-02-19 09:24:32
问题 I use -XX:OnOutOfMemoryError=\"kill -9 %p\". It works for most of out of memory cases, but it doesn't kill the process for java.lang.OutOfMemoryError: unable to create new native thread. 回答1: It may well be that the system cannot handle any more threads. That, unfortunately, would also mean that no new processes can be created - but the kill command would run as a new process! A rather unpleasant Catch-22... 来源: https://stackoverflow.com/questions/23373117/xxonoutofmemoryerror-doesnt-work-for

Order of memory allocation in C

淺唱寂寞╮ 提交于 2021-02-19 06:09:33
问题 I am trying to understand how the computer/OS/compiler (not sure who owns memory allocation, hence my noob-ish questioon) assigns memory addresses to local variables. I have this simple program: #include <stdio.h> int main(int argc, char** argv) { printf("hello, world\n"); int arr[10]; int a = 1; int b = 2; int c; for (int i = 0; i < 10; i++) { printf("Variable i: %p\n", &i); printf("Variable arr[i]: %p\n", &arr[i]); } printf("Variable a: %p\n", &a); printf("Variable b: %p\n", &b); printf(

Order of memory allocation in C

梦想的初衷 提交于 2021-02-19 06:05:48
问题 I am trying to understand how the computer/OS/compiler (not sure who owns memory allocation, hence my noob-ish questioon) assigns memory addresses to local variables. I have this simple program: #include <stdio.h> int main(int argc, char** argv) { printf("hello, world\n"); int arr[10]; int a = 1; int b = 2; int c; for (int i = 0; i < 10; i++) { printf("Variable i: %p\n", &i); printf("Variable arr[i]: %p\n", &arr[i]); } printf("Variable a: %p\n", &a); printf("Variable b: %p\n", &b); printf(

How to detect a memory overrun?

假装没事ソ 提交于 2021-02-19 05:33:45
问题 How to detect memory overrun in your 24/7 application, such as an online game server? The system and tool is linux + gcc. Sometimes the cause of the memory overrun is writing the memory beyond the array; and sometimes the cause of the memory overrun is invalid pointers. So, does anyone have some experience with this and know how to prevent it? 回答1: Prevention (at code level): Watch out the warnings of your compiler Use a static code checker Use strong coding guidelines Detection (at run-time)

how to 'Zero out' from memory an AES SecretKeySpec Key in Java

放肆的年华 提交于 2021-02-19 02:25:27
问题 I am using Java AES encryption using SecretKeySpec(byte[] key, String algorithm) to generate a Key object. After I encrypt something, I want to remove the Key from memory. I can remove all references to the Key, but that does not guarantee that the key is not floating somewhere in memory. I can "zero out" the byte[] array that I used to generate the Key, but how can I zero out or flush the actual Key memory. 回答1: There doesn't appear to be a way to do this in Java versions up to 7, but it has

Memory allocations in Julia

天大地大妈咪最大 提交于 2021-02-18 21:01:44
问题 I'm extremely dissatisfied after translating a program from Python to Julia: for small/very small inputs, Python is faster for medium inputs, Julia is faster (but not that much) for big inputs, Python is faster I think the reason is that I don't understand how memory allocation works (autodidact here, no CS background). I would post my code here but it is too long and too specific and it would not be beneficial for anybody but me. Therefore I made some experiments and now I have some

When do I have to free memory?

十年热恋 提交于 2021-02-18 20:53:07
问题 I learned C# and now I'm learning C++. The whole point of releasing a memory is new for me, and I want to know when I need to worry about memory releasing and when I don't. From what I understand, the only case I have to worry about the release of memory, is when I used new operator, so I should to release the memory by using delete . But in these cases there is no need to release the memory: Class variables (Members), or static variables. Local variables in function. STL family (string, list

What does the “new ” keyword in .net actually do?

微笑、不失礼 提交于 2021-02-18 05:24:39
问题 I know that the new keyword is calling the class constructor but at which stage do we allocate memory for the class? In my understanding it should correspond to the GCHandle.Alloc(Object) method but I'm unable to find the connection. 回答1: The new operator is implemented in the CLR. It allocates memory from the garbage collected heap and executes the class constructor. GCHandle.Alloc() is not the same. That takes advantage of a separate mechanism in the GC to create references to objects,