Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - More String Problems (Out of Memory)

More String Problems (Out of Memory)

Discuss PocketC for CE (including Desktop Edition)

Postby Glasswalker on Thu Sep 19, 2002 12:24 am

Well these are not really string problems... the same problem I had last post...

The out of memory error...

The odd thing is, I experimented... it is happening before even the main() function is calling... (the arrays I am declaring are global)

So I assumed it was because the arrays were too large...

So I compressed the data tons (eliminated non needed data) and fixed the structs some...

here are my new structs:

struct1:
13 Ints
12 Strings

Struct2:
2 strings
1 int
1 array of ints with 25 elements

I then defined an array of struct1 with 250 elements... and an array of struct2 with 50 elements... out of memory...

so I define only the struct1 array, no out of memory error... it works fine... so I figure: "OK I am just barely over the limit, I will just reduce it a bit..."

So I reduced the array1 to 150 elements and array2 to 25 elements...

Still out of memory error...
so now I am confused...

So I go back and reduce Struct1 to 10 elements and struct2 to 25 elements...

STILL Out of memory error....

Now I am highly confused...

So I experiment further...

I turn them both down to arrays with only 1 element (I know that is not really an array but whatever)

and STILL out of memory...

Also it should be noted that if the globals are defined at all, the program takes like a minute to start up... if I comment out these global arrays, then it starts instantly with no memory error...

So I turn Array1 back up to 150, and comment out array2... starts fine with no memory error... and it starts fast...

Turn array1 off and Array2 on, with 25 elements, and it takes a week to start and gives memory error...

I can crank array1 up to a few hundred and it runs fine, but array2 at just 1 element eats up all the memory...

The odd part is array2 is just 2 ints(one array) and 2 strings... what is wrong with this picture???

Here is the struct definition and the declaration of the global array:

struct armyrecord
{
string name;
int points;
string notes;
int unit[25];
};

struct armyrecord armydatabase[25];

If those lines are in the program it gives memory error... if not it does not give memory error... and the other struct which should be larger I can have a few hundred elements with no problem...

also if I reduce this definition to this:

struct armyrecord armydatabase[2];

then it still takes a week to start up and it still gives memory error... and that is with no other arrays defined...

Odd... I am completely confused by this one...

I can post the complete source if you want, but if you have any other suggestions or know any tricks I should be aware of please let me know...

thanks...
Glasswalker
 
Posts: 47
Joined: Wed Mar 21, 2001 12:18 am
Location: Canada

Postby guy on Thu Sep 19, 2002 8:35 am

How about declaring a pointer to the arrays as a global and allocating the arrays locally in main().

I remember PocketC having lots of problems with large global arrays before.


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Glasswalker on Thu Sep 19, 2002 10:04 am

How would I do that?

in order to declare a pointer don't you have to allready have declared the object it is pointing to? so how would I declare a global pointer to an array that sits inside a function that has not run yet?
Glasswalker
 
Posts: 47
Joined: Wed Mar 21, 2001 12:18 am
Location: Canada

Postby guy on Thu Sep 19, 2002 2:13 pm

You don't have to say what it's pointing to when you declare it.

Just use:

pointer gpBigArray ;

outside of the functions.

Then in the function that allocates the memory just use:

gpBigArray = malloc(....) ;




Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Mickle on Thu Sep 19, 2002 9:42 pm

Do not use global structs (and global array of structs).
PocketC not can work with global struct (bug).

If you want work with big arrays:
1. PocketC needed 2 MB for array with 65535 elements
2. PocketC needed big time for allocate memory
( and time to allocate dynamic memory == time to allocate memory in stack)

You can use "real" memory for work with big arrays.

Mickle.
Mickle
 
Posts: 48
Joined: Wed Apr 17, 2002 1:22 am
Location: Russia


Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 1 guest

cron