This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there something like maximum size of structure or array?

Hi.

I faced very weird problem.

below is my structure of custom array; if I set MAX_MYARRAYCOUNT as 20, it's OK. but if I set MAX_MYARRAYCOUNT as over 30, device crushed(iPhone can't find device).

What's going on here?? very weird.

Any suggestion of solution here? Should I use dynamic linked list?

Thanks.

#define MAX_MYARRAYCOUNT 20

typedef struct _MyArray

{
	int intValue[MAX_MYARRAYCOUNT];
	double floatValue[MAX_MYARRAYCOUNT];
	int sec[MAX_MYARRAYCOUNT];
	int cnt;
	int pt;
}MyArray;
  • Not enough information. Is this a static structure or something inside a function? If it's inside a function then you're creating this on the stack, int is 4 bytes, double on my system is 8 bytes, so that structure is 16 x MAX_MYARRAYCOUNT + 8 bytes, at 20 that's 328 bytes, at 30 it's 488 bytes. If that's a local on-stack structure, you may have run out of stack space if your stack is close to other data or you're tight on memory.

    As for the crash (it's crash, not crush), put a debugger on the thing and find out what it's doing, perhaps you are in an error handler or fault handler, which may tell you what the problem is.

Related