How should I manage memory in my mission critical embedded application?
I found some articles with google, but couldn't pinpoint a really useful practical guide.
The DO-178b forbids dynamic memory allocations, but how will you manage the memory then? Preallocate everything in advance and send a pointer to each function that needs alloc...
I have a file with the structure like so: http://gamedev.pastebin.com/8iESYTVY
but it's much bigger in size, 233MB, how can I read blocks of lines, enough lines to represent 10MB, into memory so I won't have to read in the whole file?
...
Is this valid C++ (e.g. not invoking UB) and does it achieve what I want without leaking memory? valgrinds complains about mismatching free and delete but says "no leaks are possible" in the end.
int main() {
int* a = new int[5];
for(int i = 0; i < 5; ++i)
a[i] = i;
for(int i = 0; i < 5; ++i)
delete &a[i];
}
The reason...
Hi guys,
Is there a good application (that has some kind of gui) for testing memory leaks in c code. I would really like to test my assignment/programme but being very new to this, i struggle with using the terminal to do things, especially using gdb for debugging (to me it feels like a blast from the past, where i could be using some v...
I'm new to memory-management, and am reading different things about how to best release properties.
If I have:
in .h:
@property(retain) NSString *myStr;
and in .m:
@synthesize myStr = _iVarStr;
Should my dealloc have:
[_iVarStr release];
or
self.myStr = nil;
or something else?
Thanks!
...
Hi,
I'm using the following method in my code:
- (NSMutableArray *) newOrderedArray:(NSMutableArray *)array ByKey:(NSString *)key ascending:(BOOL)ascending {
NSSortDescriptor *idDescriptor = [[NSSortDescriptor alloc] initWithKey:key ascending:ascending];
NSArray *sortDescriptors = [NSArray arrayWithObject:idDescriptor];
N...
I've written the following code:
N_Vector_cuda v;
if (N <= 0) return(NULL);
v = (N_Vector_cuda) malloc(sizeof *v);
if (v == NULL) return(NULL);
v->inc = 1;
v->elemsize = sizeof(real);
v->status = cublasAlloc(N, v->elemsize, (void**)&(v->data));
if (v->status != CUBLAS_STATUS_SUCCESS)
{
free(v);
return(NULL);
}
v->length = ...
I'm creating a reporting application, and our customers are going to need to generate some pretty big reports which require quite a bit of memory. Ive been in a re-factoring mood lately, so I was wondering what the best way to access the properties of another open form would be(The reporting viewer opens in a new form.) So far I have:
...
I am a beginner in C. While reading git's source code, I found this wrapper function around malloc.
void *xmalloc(size_t size)
{
void *ret = malloc(size);
if (!ret && !size)
ret = malloc(1);
if (!ret) {
release_pack_memory(size, -1);
ret = malloc(size);
if (!ret && !size)
ret = mal...
I tracked down a memory leak with instruments. I always end up with the information that the responsible library is Foundation. When I track that down in my code, I end up here, but there's nothing wrong with my memory management:
- (void)setupTimer {
// stop timer if still there
[self stopAnimationTimer];
NSTimer *timer = ...
I init a navigation controller with:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
I wonder if the navigation controller retains firstViewController or that I need to keep it alive. When I release firstViewController, the navigation controller still works. That...
I am not sure if both of these works to delete:
p = new int[1];
delete p
and
delete [] p;
If both work, what is the difference between the above two deletes?
...
On WindowMobile 6.1, I am using VirtualAlloc to reserve 2MB chunks, which will return me an address from the large shared memory area so allocations do not count against my per process virtual space.
(doc here: http://msdn.microsoft.com/en-us/library/aa908768.aspx)
However, on some devices i notice that I am not able to reserve memory ...
Hi,
I have a problem with the memory management in Objective-C. Say I have a method that allocates an object and stores the reference to this object as a member of the class. If I run through the same function a second time, I need to release this first object before creating a new one to replace it. Supposing that the first line of ...
I have a Linux app (written in C) that allocates large amount of memory (~60M) in small chunks through malloc() and then frees it (the app continues to run then). This memory is not returned to the OS but stays allocated to the process.
Now, the interesting thing here is that this behavior happens only on RedHat Linux and clones (Fedor...
What are the consequences (positive/negative) of using the unsafe keyword in C# to use pointers? For example, what becomes of garbage collection, what are the performance gains/losses, what are the performance gains/losses compared to other languages manual memory management, what are the dangers, in which situation is it really justifia...
According to the UIImage documentation:
In low-memory situations, image data may be purged from a UIImage object to free up memory on the system.
Does anyone know how this works? It appears that this process is completely transparent and will occur in the background with no input from me, but I can't find any definitive documentati...
I have a piece of code where I can call destructor multiple times and access member functions even the destructor was called with member variables' values preserved. I was still able to access member functions after I called delete but the member variables were nullified (all to 0). And I can't double delete. Please kindly explain this. ...
My C++ program needs a block of uninitialized memory and a void* pointer to that block so that I can give it to a third party library. I want to pass control of the block lifetime to the library, so I don't want to use std::vector. When the library is done with the block it will call a callback that I have to supply and that will dealloc...
Hi,
I am new in objective-c and I am trying to understand memory management to get it right.
After reading the excellent
Memory Management Programming Guide for Cocoa by apple my only concern is when
actually an autoreleased object is released in an iphone/ipod application. My understanding is at the end of a run loop. But what define...