// ClassA.m
NSString *strA = [[NSstring alloc] initWithString:@"test string"];
ClassB *classB = [[ClassB alloc] init];
[classB setStrB:strA];
[strA release];
// classB will be released later
// ClassB.h
@property (nonatomic, retain) NSString *strB;
// ClassB.m
// custom setter
-(void) setStrB:(NSString *)newStr {
strB = newStr...
Does either of these methods use more memory than the other or put a larger load on GC?
Option #1
LargeObject GetObject()
{
return new LargeObject();
}
Option #2
LargeObject GetObject()
{
LargeObject result = new LargeObject();
return result;
}
...
There is a memory leak happens in an application when a short lived object holds a long lived object,
My question is how can we identify
1) which object lives longer and shorter, any tool which measures life of an object?
2nd Question
I am constantly getting the Out of Memory Space Error and I tried increasing the Heap memory to 2 GB...
I have an app that often crashes on the device (iPad), but not on the simulator, so any simulator debug tactics (MallocStackLogging for example) are not an option. What I usually get in the console is this:
Received memory warning. Level=1
Received memory warning. Level=2
Program received signal: “0”.
Data Formatters temporarily unavai...
I thought that the delete command would free up memory I allocated. Can someone explain why it seems I still have the memory in use after delete?
class Test
{
public:
int time;
};
int main()
{
Test *e;
e = new Test;
e->time = 1;
cout << e->time << endl;
delete e;
e->time = 2;
cout << e->time << endl;...
I'm having difficulties to understand exactly WHEN autorelease pools are created and released in AppKit apps.
For example, if I have an ApplicationController class that overrides init, is there an autorelease pool that gets created before it starts and gets drained after it ends?
...
I need to create Solution Architechure for Windows Mobile and have following queries:
My application is like a service that will start in phone startup and that should run in background and have no UI (this is not a problem). I am using third party dlls (with source code) in my project. Does windows mobile have any problem of loading dl...
Maybe this a newbie question, but according to my instruments there is a leak there, but im releasing the imageRef. i cant figure it out. its a category function.
-(UIImage *)imageAtRect:(CGRect)rect
{
CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], rect);
UIImage* subImage = [UIImage imageWithCGImage: imageRef];
CG...
We're getting a very curious error in our application.
java.lang.InternalError: Memory Pool not found
for ( final MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans() ) {
final MemoryUsage usage = bean.getUsage(); // Error thrown on this line
System.out.println(usage);
}
What does this error mean, and how do I resol...
NSMutableArray *myArray = [[NSMutableArray alloc] init];
MyClass *obj1 = [[MyClass alloc] init];
[myArray addObject: obj1];
How to clean the old obj1 reference here, if I want to reuse the variable name. Without destroying anything in the array.
obj1 = nil
OR
[obj1 release];
// What is the differences?
obj1 = [[MyClass alloc] in...
I have a situation where I need to work with a number (15-30) of large (several hundreds mb) data structures. They won't fit into memory all at the same time. To make things worse, the algorithms operating on them work across all those structures, i.e. not first one, then the other etc. I need to make this as fast as possible.
So I figu...
I am a C++ programmer currently trying to work on Java. Working on C++ I have an habit of keeping track of dynamic memory allocations and employing various techniques like RAII to avoid memory leak. Java as we know provides a Garbage Collector(GC) to take care of memory leaks.So while programing in Java should one just let go all the who...
Hi,
1) Does adding a Dispose(), or finalize method, have any impact on making an object be GC'd soon? I ask this as my manager wrote some code, adding a finalize() method, in the hope it would be GC'd.
But I argued that the object has to be "marked" for collection first, if it meets certain criteria.
2) Does writing "o = null" (where ...
greetings and apologies if this is a repost (i searched this site, and i believe its not a repost, though)
I work with scilab, but during a project, scilab has to deal with a large number of variables.
I was wondering if i can do the following
var_list = who_user();
for _var_ = var_list do
if _var_ is global then
writetofile(huma...
Hi all, I am trying to display a modal view controller containing a NavigationController. I can't figure out where to release the controllers, though. Normally, I would just release the controller after displaying it, but that won't work here; presumably that has something to do with the navigation controller. Any help would be great...
Hi, I have a vector that I fill with pointers to objects. I am trying to learn good memory management. I have a few general questions:
Is it true that when I am done with the vector I must loop through it and call delete on each pointer?
Why don't I have to call delete on the vector (or any other variable I declare without the new stat...
Sometimes I wonder when something gets autoreleased. I added an NSLog in the dealloc of various objects, but I couldn't find anything useful.
When does something release when autorelease is used? Is it unpredictable, or is there some extra thread running? Thanks.
...
Hello, all.
I am working on modifying a relatively large C++ program, where unfortunately it is not always clear whether someone before me used C or C++ syntax (this is in the electrical engineering department at a university, and we EEs are always tempted to use C for everything, and unfortunately in this case, people can actually get ...
Basically I have this scenario going on:
//in interface header
@property(nonatomic,retain)OtherClass *otherClass;
//implementation
- (id)initWithOtherClassInstance:(OtherClass*)otherClass
{
if (self != [super init])
return self;
self.otherClass = otherClass;
return self;
}
- (void)dealloc
{
//Do I need...
I'm trying to figure out what the recommended practice is for the following situation. Certain objects, such as CLLocationManager or MKReverseGeocoder, send their results asynchronously to a delegate callback method. Is it OK to release that CLLocationManager or MKReverseGeocoder instance (or whatever class it may be) in the callback met...