http://www.yolinux.com/TUTORIALS/C%2B%2BMemoryCorruptionAndMemoryLeaks.html
Memory leak in Java
http://info.appdynamics.com/rs/appdynamics/images/Top_10_Java_Performance_Problems_eBook.pdf
http://stackoverflow.com/questions/6470651/creating-a-memory-leak-with-java
http://www.agiledeveloper.com/articles/MemoryLeak092002.pdf
http://www.openlogic.com/wazi/bid/188158/How-to-Fix-Memory-Leaks-in-Java
http://www.cs.utexas.edu/users/speedway/DaCapo/papers/leak-tr-06-07.pdf
Avoiding memory leaks in POSIX thread programming
Listing 1. Creating a memory leak
#include<stdio.h>
#include<pthread.h>
void run() {
pthread_exit(0);
}
int main () {
pthread_t thread;
int rc;
long count = 0;
while(1) {
if(rc = pthread_create(&thread, 0, run, 0) ) {
printf("ERROR, rc is %d, so far %ld threads created\n", rc, count);
perror("Fail:");
return -1;
}
count++;
}
return 0;
}
Preventing leaks
Joinable threads should be joined during programming. If you are creating joinable threads in your program, don't forget to call
http://hea-www.harvard.edu/~fine/Tech/addrinuse.html
pthread_join(pthread_t, void**) to recycle the private storage allocated to the thread. Otherwise, you'll introduce serious memory leaks.http://hea-www.harvard.edu/~fine/Tech/addrinuse.html
No comments:
Post a Comment