Is there a way to find out what the maximum number of bytes available is when using malloc in c?
Or do you just have to do it and check errno and/or the pointer to see if you succeeded? ...
Or do you just have to do it and check errno and/or the pointer to see if you succeeded? ...
I am writing some guidelines for the company and I need to answer some tough questions. This one is quite difficult. The solution can be: Not track at all. Make sure that objects are allocated using new which will throws an exception when allocation failed. The application will die, and it is not a big deal. PRO - code usually can be...
I'm designing a high level language, and I want it to have the speed of C++ (it will use LLVM), but be safe and high level like C#. Garbage collection is slow, and new/delete is unsafe. I decided to try to use "region based memory management" (there are a few papers about it on the web, mostly for functional languages). The only "useful"...
Suppose I have a function like this: - (NSSet *) someFunction { //code... return [[[NSSet alloc] initWithObjets:obj1, obj2, nil] autorelease]; } When I call this function, do I need to do retain/release the return value? I'm assuming I do. However, what if I don't do autorelease, so someFunction now looks like this: - (NSSet...
I'm currently working on a C based application am a bit stuck on freeing memory in a non-antipattern fashion. I am a memory-management amateur. My main problem is I declare memory structures in various different scopes, and these structures get passed around by reference to other functions. Some of those functions may throw errors and e...
I have a couple of views that access the movie player. I've put the following code in a method in AppDelegate for these views. They send in the filename to play. The code works fine but I know a release is required somewhere. If I add the last line as a release or autorelease, the app will crash once the user presses done on the movi...
Suppose I have a class like this: @interface SomeClass : NSObject<NSCopying> { SomeOtherClass *obj; } In the definition of copyWithZone:, I do this: SomeClass *someCopy = [[SomeClass allocWithZone:zone] init]; So my question is, if I want to make a copy of obj, which of these is correct/recommended? option A: objCopy = [obj c...
I was thinking that when a function returns an object on the stack to the calling function, the calling function gets a copy of the original object but the original object's destructor is called as soon as the stack unwinds. But in the following program, the destructor is getting called only once. I expected it to be called twice. #incl...
Are .NET collections with large number of items apt to be stored in the LOH? I'm curious about List and Dictionary specifically. In my code, I store a large number (40k+) of relatively small objects (lets say 1k) in temporary Lists and Dictionarys for processing. Does the number of items in these collections increase the likelihood of b...
I am writing an application and am surprised to see its total memory usage is already too high. I want to profile the dynamic memory usage of my application: How many objects of each kind are there in the heap, and which functions created these objects? Also, how much memory is used by each of the object? Is there a simple way to do thi...
I can't use shared_ptr in my project, no boost :( So, I'm having a class roughly similar to the one below: class MyClass { private: std::auto_ptr<MyOtherClass> obj; }; Now, I want to store the instances of above class in std::vector. Is it safe? I've read here that it's wrong to use std::auto_ptr with STL containers. Does it apply ...
I have to use a UITabBarController inside UINavigationController. Everything seems to be right, but if i log the dealloc calls of the tabs some strange thing happens. If I don't touch eanything just the back button, all dealloc of each tabs are called. If I switch to any other tab and than I tap the back button the dealloc of the first ...
public sealed class FtpManager { public event EventHandler LoggingIn = delegate { }; private void OnLoggingIn(object sender, EventArgs e) { var handler = LoggingIn; handler(sender, e); } // ... } In the above code, I have initialized LoggingIn event handler with an empty delegate. Will that affect memory...
Does anyone know how exactly RSLs work with AIR? I have a terminal server that runs several instances of a very large AIR application, which unfortunately has 100M RAM on startup and 200 after a bit of use. This is obviously not really workable, and I'm thinking that RSLs may be a solution if they're cached on the machine. However I have...
- (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? ...
I am looking for good explanations out there. I have a 1000 pages book about objective-c, but unfortunately the part about memory management, retain counting, is described pretty bad and hard to understand. ...
We are running an web application that is using Java 64bit 5 gigs of -Xmx of maximum heap size. We have no control over the java code. We can only tweak configuration parameters. The situation that we are facing is that the java processes after it takes the full heap allocated at start up, it starts acting very responding very slow to...
In a simple list, ex : struct Node { Node *next; void *data; } is there any problem if i allocate Node and Data in a single allocation (provided i know the size), like Node * t = (Node*)malloc(sizeof(Node) + DataSize)); and always assign data at the end of allocated chunk, t->data = (BYTE*)t+ sizeof(Node); /* BYTE...
How does one implement alloca() using inline x86 assembler in languages like D, C, and C++? I want to create a slightly modified version of it, but first I need to know how the standard version is implemented. Reading the disassembly from compilers doesn't help because they perform so many optimizations, and I just want the canonical f...
I am trying to make NSTableDataSource compatible object and give this object to NSTableView as DataSource, however when table tries to display data, it crashes. @interface NSArrayDataSource : NSObject{ NSArray* internalArray; } -(id) initWithArray: (NSArray*) objects; -(int)numberOfRowsInTableView:(NSTableView *)aTableView; -(id)ta...