memory-leaks

Problem with memory leaks

Sorry, having difficulty formattin code to appear correct here??? I am trying to understand the readings I get from running instruments on my app which are telling me I am leaking memory. There are a number, quite a few in fact, that get reported from inside the Foundation, AVFoundation CoreGraphics etc that I assume I have no contr...

pointers in structs a memory leak?

I couldn't find any mention of this online... wouldn't putting a pointer in a struct be a bad thing? (at least in the modern object oriented programing) The programmer would inevitably creating a memory leak correct? (unless they, every time they use it, they disassociate the memory every time) Assuming that the above is correct... is i...

Pointers in For loops

Quick question: I am a C# guy debugging a C++ app so I am not used to memory management. In the following code: for(int i = 0; i < TlmMsgDB.CMTGetTelemMsgDBCount(); i++) { CMTTelemetryMsgCls* telm = TlmMsgDB.CMTGetTelemetryMsg(i); CMT_SINT32_Tdef id = telm->CMTGetPackingMapID(); ManualScheduleTables.SetManualMsg(i,id); ...

stringWithContentsofurl generate leaks

Hi, im trying to get data via NSString *string = [NSString stringWithContentsOfURL: [NSURL URLWithString: url]]; everything works fine, but when I run it with performance tool, it finds leaks on this line. Here is whole mehod I use: - (NSMutableDictionary *) getOutputImagesData: (URLParserImagesData) data { NSString *t...

Why isn't my Ruby object deleted when the last reference goes out of scope?

Hi gurus, I've found a weird effect when trying to track down a memory leak in a Rails app. Can anyone explain what's going on here? Save this script as a plain Ruby script (Rails not necessary): class Fnord def to_s 'fnord' end end def test f = Fnord.new end test GC.start sleep 2 ObjectSpace.each_object do |o| ...

What will happen if I forgot to release the object in iPhone App?

Will it auto release when the user quit the application? or it will stay in the machine until reboot? Also, have Apple provides any tools for developer to check whether they release the object or not. ...

iPhone: Newbie memory management question

I am just getting started with cocoa. So please excuse the silly question, but I can't quite wrap my head around some aspects of memory management yet. In the interface of my class I am declaring an object as CEMyObjectclass *myObject;. I do not alloc or init the obect in the classe's init menthod. But I do have a method that calls myOb...

A strategy to troubleshoot/ fix application crashes in Windows?

All, Over a period of time I have observed that fixing issues related to application crash is a discipline in itself. Some people have this nice way of attacking such problems. Ranging from Viewing the 'Event Viewer' to running Static/ Dynamic memory analysis tools to some of their 'personal favorites', these people have developed this ...

Python Memory leak - Solved, but still puzzled

Dear everyone, I have successfully debugged my own memory leak problems. However, I have noticed some very strange occurence. for fid, fv in freqDic.iteritems(): outf.write(fid+"\t") #ID for i, term in enumerate(domain): #Vector tfidf = self.tf(term, fv) * self.idf( term, docFreqDic) ...

iPhone: CALayer Memory Leak question

Would the code bellow cause my code to leak? More specifically, am I responsible for releasing the newImage or the contents of mainPageLayer (which is a CALayer object)? I get a memory warning every 4th time that method is called, but cant figure out why... I also can't figure out why mainPageLayer.contents = [newImage CGImage]; throws ...

How do I mock memory allocation failures ?

I want to extensively test some pieces of C code for memory leaks. On my machine I have 4 Gb of RAM, so it's very unlikely for a dynamic memory allocation to fail. Still I want to see the comportment of the code if memory allocation fails, and see if the recover mechanism is "strong" enough. What do you suggest ? How do I emulate an en...

How does the destructor know when to activate itself? Can it be relied upon?

Say for example i have the following code (pure example): class a { int * p; public: a() { p = new int; } ~a() { delete p; } }; a * returnnew() { a retval; return(&retval); } int main() { a * foo = returnnew(); return 0; } In returnnew(), would retval be destructed after the return of the funct...

Is there any reasonable use of a function returning an anonymous struct?

Here is an (artificial) example of using a function that returns an anonymous struct and does "something" useful: #include <iostream> template<typename T> T* func( T* t, float a, float b ) { if(!t) { t = new T; t->a = a; t->b = b; } else { t->a += a; t->b += b; } retu...

memory leak in php script

Hi, I have a php script that runs a mysql query, then loops the result, and in that loop also runs several queries: $sqlstr = "SELECT * FROM user_pred WHERE uprType != 2 AND uprTurn=$turn ORDER BY uprUserTeamIdFK"; $utmres = mysql_query($sqlstr) or trigger_error($termerror = __FILE__." - ".__LINE__.": ".mysql_error()); whil...

What are the ramifications of using System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(path)) in T4?

System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(path)) So this is a work around to not being able to use T4 to reflect or read other files in the project or solution without locking the binaries from this post. The comments imply a memory issue. The comments talk about a no-unloading downside, would this be garbage collect...

C++ Memory Leak, Can't find where

I'm using Visual Studio 2008, Developing an OpenGL window. I've created several classes for creating a skeleton, one for joints, one for skin, one for a Body(which is a holder for several joints and skin) and one for reading a skel/skin file. Within each of my classes, I'm using pointers for most of my data, most of which are declared u...

Signal "0" error while scrolling a tableview with images

Hi, I have a problem while scrolling images on tableview. I am getting a Signal "0" error. I think it is due to some memory issues but I am not able to find out the exact error. The code is as follows, - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSStri...

iPhone, Convenience Method or Alloc / Release?

Whilst developing for the iPhone I had a stubborn memory leak that I eventually tracked down to NSXMLParser. However whilst looking for that it got me thinking about maybe changing a lot of my convenience methods to alloc/release. Is there any good reason for doing that? In a large app I can see how releasing memory yourself quickly is a...

iPhone, confusing memory leak.

Can anyone tell me what I am doing wrong with the bottom section of code. I was sure it was fine but "Leaks" says it is leaking, which quickly changing it to the top version stops, just not sure as to why? // Leaks says this is OK if([elementName isEqualToString:@"rotData-requested"]) { int myInt = [[self elementValue] intValue]; ...

Reading email address from contacts fails with weird memory issue - Solved

Hi all, I'm stumped. I'm trying to get a list of all the email address a person has. I'm using the ABPeoplePickerNavigationController to select the person, which all seems fine. I'm setting my ABRecordRef personDealingWith; from the person argument to - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)pe...