I am allocating memory in a C program using malloc. It's possible for my program to allocate more memory than the system has room for, at which point the program crashes. For my purposes it would be better if malloc would just return NULL (like it's apparently supposed to), so I can catch the error. Instead what it does is it throws an e...
#include<stio.h>
main()
{
int *p,i;
p = (int*)malloc(sizeof(int));
printf("Enter:");
scanf("%d",p);
for(i=1;i<3;i++)
{
printf("Enter");
scanf("%d",p+i);
}
for(i=0;i<3;i++)
{
printf("No:%d\n",*(p+i));
}
getch();
return 0;
}
In this C program memory is accessed without allocation.The program works.Wi...
I'm using a MPMoviePlayerController in my iPhone app to display some short video clips sometimes. I deaclared a Category which ads a couple methods to the class to properly attach its view to a particular view and to remove it from there.
I use the notification system to let a class know when the movie has finished playing, then I try to...
I recently read a lot about "preventing heap allocation for a class" (see this question).
I was able to understand "how", but now I can't figure out "why" someone would like to do that.
I guess there must be legitimate reasons for this, but I just can't figure them out.
In short: "Why may I want to forbid users from creating objects o...
I am trying to make some memory executable (on Mac OS 10.6), and I suspect that mprotect() is failing silently. Given the address of a page of memory, how can I check that it is in fact marked executable?
...
Hey all,
I'm wondering if there is a simple command or instruction in C#/.NET and/or Visual Studio that can tell me how much memory an individual object is taking up? I have a sneaking suspicion that the sizeof() operator is going to lie to me ... am I justified in this belief?
There is a somewhat related question here, but no definit...
When in doubt, turn to Stackoverflow...
I'm having a problem with string allocation. My goal is to store n length of a passed quoted string. I check m_p for null because I think in debug mode MS likes to set the address to 0xcccccccc instead of 0x00000000.
I passed 1 into length. But when I allocate it using new, I'm getting about 15 ...
As the title says, how can I find a free block to be allocated at the highest virtual address using only the POSIX API?
...
I'm using openURL to send an email w/some links. The function looks like this:
//
+ (void) sendEmail:(NSString *) subject withBody:(NSString *)body {
NSString *mailString = [NSString stringWithFormat:@"mailto:?@&subject=%@&body=%@",
[subject stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[body stringBy...
From a related thread, how should I have known the "mailString" below was already autoreleased?
//
+ (void) sendEmail:(NSString *) subject withBody:(NSString *)body {
NSString *mailString = [NSString stringWithFormat:@"mailto:?@&subject=%@&body=%@",
[subject stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
...
Continuing some helpful StackOverflow debugging, I have a zombie I need to track down:
2010-08-22 10:18:51.111 AppName[106:307] *** -[CFString release]: message sent to deallocated instance 0x19f3b0
How would one find the variable name or whathaveyou for the 0x19f3b0 Zombie?
...
I am trying to debug some stuff and while I'll also RTFM can anyone tell me how to check the allocation of a memory address in XCode? The text I automatically jump to on the error is not immediately decipherable. In an ideal world I'd like to figure out the name of the variable (or at least its contents) that I just re-released.
An exam...
Hi All,
My website is using a lot of memory and I have downloaded the trial of ANTS Memory Profiler. The site is using XML files to store the the categories and the items that belong in those categories - I then traverse the files (4mb for the categories file and about 800kb for the items file stored on the local machine (web server)) a...
Hey,
What's the equivalent to Windows's VirtualAlloc in OS X? That is, how can i reserve a contiguous address space without actually commiting it and then commit chunks of it later?
Thanks,
Alex
...
I wrote an app compiled against ios 3 that would easily allocate up to 100 mb of memory for image processing purposes. However, when that same app was compiled against the ios 4 sdk, I found that it crashed when many apps were open in the background. When I kill the background apps, the application then runs fine. I reduced the memory us...
Hi,
I am experimenting with the c-language right at the moment, yet i have some trouble with memory allocation. After some time i have to restart my computer because my memory runs full. Is there a way to let the compiler tell me which arrays do not get deallocated after the program has run?
Thx for answers
...
I have a simple question. I was referring "Your first iOS application" document by apple.I found that the class has a property called myViewController:
@interface applicationClass
{
MyViewController *myViewController
}
Now to assign a memory to this pointer, the code shown is:
MyViewController *aViewController = [[MyViewController...
In my application (Delphi 2010, OpenGL, windows XP), I need to read back the pixels of variable portions of the framebuffer.
The area of interest is input by the user through a selection rectangle (x1, y1, x2, y2).
With this coordinates I do this:
var
pixels : PGLUByte; //pointer to unsigned bytes
begin
[Transformation of...
Hi everyone,
I have RootViewController and DetailsViewController in my iPhone application. I use Allocations tool to monitor my memory consumption, and I have a question.
When my app starts it takes around 4Mb memory, when I select item in RootViewController it loads UIWebView in DetailsViewController and memory rise up to 10Mb, after...
I was trying to use a union to so I could update the fields in one thread and then read allfields in another thread. In the actual system, I have mutexes to make sure everything is safe. The problem is with fieldB, before I had to change it fieldB was declared like field A and C. However, due to a third party driver, fieldB must be allig...