Consider the following method, where I build a string and return it. I would like to release the building blocks of the string, but then the string is based on values that no longer exists. Now what?
Am I leaking memory and if so, how can I correct it?
- (NSString) getMiddahInEnglish:(int)day{
NSArray *middah = [[NSArray alloc] initWi...
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...
Hi,
I would really appreciate if someone could tell me whether I understand it well:
class X
{
A a1=new A(); // reference on the stack, object value on the heap
a1.VarA=5; // on the stack - value type
A a2=a1; // reference on the stack, object value on the heap
a2.VarA=10; // on the stack - value type
}
...
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);
...
Hi,
I've been spending the last few hours trying to find the memory leak in my code. Here it is:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
expression = [expression stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]]; // expression is an NSString object.
NSArray *argument...
I saw a question yesterday which raised (for me) another question. Please look at the following code:
public class Class1
{
int A; //as I uderstand, int is value type and therefore lives in the stack
}
class Class2
{
Run()
{
Class1 instance1 = new Class1();
instance1.A = 10; //it points to value type, but isnt ...
We are working on a Vista/Windows 7 application that will be running in 64 bit mode using VS2008/C++. We will be needing to cache hundreds of 2-3 mb blobs of data in RAM for performance reasons up to some memory limit. Our usage profile is such that we cannot read the data in fast enough if it is all on the the disk. Cached Memory usa...
If garbage collection is not required:
- (void) awakeFromNib{
//Create the NSStatusBar and set its length
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
...
Do I have to release that? And if I do, would that be in a finalize method or dealloc method?
If garbage collection is requ...
From Notification Watcher source.
- (void)selectNotification:(NSNotification*)aNotification {
id sender = [aNotification object];
[selectedDistNotification release];
selectedDistNotification = nil;
[selectedWSNotification release];
selectedWSNotification = nil;
NSNotification **targetVar;
NSArray **targetList;
if (sender == distNotifica...
I have a method which runs this:
Track* track = [[Track alloc] init:[obj objectForKey:@"PersistentID"] :[obj objectForKey:@"Name"] :[obj objectForKey:@"Artist"] :(NSInteger*)[obj objectForKey:@"Total Time"] :(NSInteger*)[obj objectForKey:@"Play Count"]];
[self setCurrentTrack:(Track*) track];
[track release];
Do I have to release tr...
I am using Delphi 2009 which has the FastMM4 memory manager built into it.
My program reads in and processes a large dataset. All memory is freed correctly whenever I clear the dataset or exit the program. It has no memory leaks at all.
Using the CurrentMemoryUsage routine given in spenwarr's answer to: http://stackoverflow.com/questi...
In C++ using delete to free memory obtained with malloc() doesn't necessarily cause a program to blow up.
Do you guys think a warning or perhaps even an assertion failure should be produced if delete is used to free memory obtained using malloc()??
Why do you think that Stroustrup did not had this feature on C++?
...
Why new()/delete() is slower than malloc()/free()?
EDIT:
Thanks for the answers so far. Please kindly point out specifications of standard C++ implementation of new() and delete() if you have them thanks!
...
Hey,
I've been writing a multi-threaded DLL for database access using ADO/ODBC for use with a legacy application. I need to keep multiple database connections for each thread, so I've put the ADO objects for each connection in an object and thinking of keeping an array of them inside a custom threadInfo object. Obviously a vector would ...
Hi,
I am currently writing a small custom memory Allocator in c++, and want to use it together with operator overloading of new/delete. Anyways, my memory Allocator basicall checks if the requested memory is over a certain threshold, and if so uses malloc to allocate the requested memory chunk. Otherwise the memory will be provided by s...
-(IBAction)registerUpdate:(id)sender {
HTTPRequest* request = [[HTTPRequest alloc] initWithUrl:@"http://www.yahoo.com" delegate:self];
[request doRequest];
}
The HTTPRequest makes an asynchronous request and calls the onHTTPResponse method in the current class.
My question is do I have to release request? My guess is that I'm ...
Hi,
Question related to PHP memory-handling from someone not yet very experienced in PHP:
If I set a PHP session variable of a particular name, and then set a session variable of the exact same name elsewhere (during the same session), is the original variable over-written, or does junk accumulate in the session?
In other words, shoul...
Hi,
I'm a beginner level programmer trying to make a game app for the iphone and I've encountered a possible issue with the memory management (exc_bad_access) of my program so far. I've searched and read dozens of articles regarding memory management (including apple's docs) but I still can't figure out what exactly is wrong with my cod...
This is my drawRect:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextMoveToPoint(context, x1, y1);
CGContextAddLineToPoint(context, x2, y2);
CGContextStrokePath(context);
If I run this code thousand times or mo...
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.
...