memory-leaks

Using Instruments Leaks & Object Alloc: Are autoreleased objects counted as leaks?

I have an iPhone app that's getting memory warnings and so I'm trying to find leaks, make more efficient use of memory, etc., with the help of Instruments. Amongst other things, I'm trying to take out any autoreleased objects and replace with manual alloc/init/release objects. However, some API calls don't appear to have an 'init' versio...

Why is my C++ code causing a segmentation fault well after using the read(...) function?

My application is suspending on a line of code that appears to have nothing wrong with it, however my IDE appears to be suspending on that line with the error: gdb/mi (24/03/09 13:36) (Exited. Signal 'SIGSEGV' received. Description: Segmentation fault.) The line of code simply calls a method which has no code in it. Isn't a segment...

Operator overloading with memory allocation?

The sentence below is from, The Positive Legacy of C++ and Java by Bruce Eckel, about operator overloading in C++: C++ has both stack allocation and heap allocation and you must overload your operators to handle all situations and not cause memory leaks. Difficult indeed. I do not understand how operator overloading has any...

How can I enable the memory leak tracking with FastMM in DUnit?

In the GUI test runner, the menu items for memory leak checking are inactive (grayed out). Is there a special switch I have not found yet to activate them? Using DUnit 9.4 (from Delphi 2009 or from the sourceforge Subversion repository) and FastMM4.92 ...

How can a Java process with -Xmx1024m occupy 3GB resident memory?

It's a Java web application on Websphere6.1, Solaris 10, JDK 1.5.0_13. We set the maximum heap size to 1024m. jmap shows the heap status is healthy. The heap memory usage is only 57%. No OutOfMemory at all. But we saw very high RSS (3GB) for this java process from ps. pmap shows a block of 1.9G private memory. 3785: /dmwdkpmmkg/was/...

Large Object Heap Fragmentation

The C#/.NET application I am working on is suffering from a slow memory leak. I have used CDB with SOS to try to determine what is happening but the data does not seem to make any sense so I was hoping one of you may have experienced this before. The application is running on the 64 bit framework. It is continuously calculating and se...

Re-assinging an "auto_ptr" and Managing Memory

I've a situation like this: class MyClass { private: std::auto_ptr<MyOtherClass> obj; public: MyClass() { obj = auto_ptr<MyOtherClass>(new MyOtherClass()); } void reassignMyOtherClass() { // ... do funny stuff MyOtherClass new_other_class = new MyOtherClass(); // Here, I want to: // 1) Delete the point...

How do I programmatically find out my PermGen space usage?

I'm trying to diagnose a java.lang.OutOfMemoryError: PermGen Space error when running on Sun's Hotspot JVM, and would like to know how much PermGen space my program is using at various points. Is there a way of finding out this information programmatically? ...

Creating memory stream from ResponseStream Out of Memory Exception

I am making a call to a httprequest which returns a pdf file in the responsestream. This works well for smaller pdf's, but not the file is up around 25-30MB, it is returning an out of memory exception. MemoryStream memStream = new MemoryStream(); byte[] buffer = new byte[2048]; int bytesRead = 0; do ...

would this cause an memory leak in iPhone?

- (void)viewDidLoad { [super viewDidLoad]; landscape.image = [UIImage imageNamed:@"tenerife1.png"]; } I assign that new UIImage to the image property of an UIImageView object. I am not sure if that would result in an memory leak? ...

ACE (C++): Not calling cancel_timer == MLK?

If a one-shot timer was scheduled via schedule_timer(timer,0,ACE_Time_Value(delay),ACE_Time_Value::zero) is cancel_timer required in order to avoid a memory leak? ...

How to track memory leaks with umdh.exe in all heaps?

I have a c++ windows application that leaks memory per transaction. Using perfmon I can see the private bytes increase with every transaction, the memory usage is flat while the application is idle. Following previous answers on stackoverflow I used umdh from the microsoft debugging tools to track down one memory leak. However there i...

Am I experiencing a memory leak, or just high memory usage in Firefox?

I'm loading some fairly big data sets in to firefox (500 k or so) and drawing tables with them. Firefox is using up to 400 megs of memory. How can I tell if Firefox is leaking memory, or is just using a lot of memory just because it can? Is there another browser which will use less memory if it doesn't need it? I get the feeling that fi...

How does a reference-counting smart pointer's reference counting work?

In other words, how does the implementation keeps track of the count? Is there a map-like object maintained which is accessible by all the shared_ptr instances whose key is the pointer's address and value is the number of references? If I've to implement a shared_ptr, this is the first idea that's coming to my mind. Is there a possibil...

Hook into another application to watch memory usage

I just started writing an application that I would like to use to attach to any running process, and get notified when it allocates or deallocates memory. I already created the interface so I can select from a list of running processes, but I don't really know how to hook into that process to get the information I'm looking for. This i...

Dedicated function for memory allocation causes memory leak?

Hy all, I believe that the following piece of code is generating memory leak? /* External function to dynamically allocate a vector */ template <class T> T *dvector(int n){ T *v; v = (T *)malloc(n*sizeof(T)); return v; } /* Function that calls DVECTOR and, after comput...

What happens to a malloc'ed block if you don't use it?

Consider the following C code: int main(){ int* c; c = (int*)malloc(sizeof(int)); c = 0xdeadbeef; free(c); return 0; } This will segfault because you are trying to free c, which is not something that has been malloc'ed before. My question is what happens to the block i just malloc'ed? Obviously c is not...

C++: Debugging memory leaks in reference counting system

I've got a number of reference counted classes in some of my applications, and also in dlls those applications use, all inheriting from and implementing a IRefCounted interface. In order to help with finding the source of these memory leaks I want each application to maintain a list of all these refrence counted classes in existance. T...

How can I leak memory in Clojure?

For a presentation at the Bay Area Clojure Meetup on Thursday I am compiling a list of ways to leak memory in Clojure. So far I have: hold onto the head of an infinite sequence creating lots of generic classes by calling lambda in a loop (is this still a problem) holding a reference to unused data ... What else? ...

Freeing memory in C

I'm having problem with this small program: UPDATED (As per some requests, I've included everything here so to make clear what I'm doing. Sorry for it being too long): Student.h file: typedef struct Student { char *name; int age; char *major; char *toString; } *Student; extern Student newStudent(char *name, int age, char *ma...