Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Out of Memory Exception Error on Load


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-29-2008, 10:12 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default Out of Memory Exception Error on Load

I am having a problem with a rather large application. When we try to run the executable on a 640x480 VGA device (an HTC Advantage or an iPaq 210 Enterprise), we get an Out of Memory Exception error.

This error does not occur on QVGA devices like the HTC 8925/AT&T Tilt.

I have narrowed the problem down to the number of forms the program has to deal with at launch. It can't handle more than 40 forms. To verify this, I created a new application that does nothing more that start up and display Form1. Then I added Form2 through Form40 (40 forms total). I compiled the executable, for the device, with optimization on, loaded it onto the VGA device, and launched it. It crashed without even displaying Form1 and reported the Out of Memory Exception error.

I then recomplied the same application with optimization off, loaded it onto the VGA device, and launched it. The program ran properly.

I just can't beleive that this program is chewing up more than 70 megabytes of free program memory and still wanting more.

So I have to do one of the following:

1.) Find a way to allocate more memory to the program.

2.) Strip forms out of my program until I'm under the limit. (The users probably won't appreciate the loss of program functions that would accompany this option.)

3.) Compile my program non-optimized, which I'm having problems doing. I use about a dozen DLLs, and I'm not sure which ones are protesting in a non-optimized compilation.

4.) Become a welder.

Anyone have any thoughts on this?


Gary

__________________
PC: Windows XP Pro SP3 / Basic4PPC v6.5
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 11:05 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi Willisgt,

I've not come across this problem before, but then I've not come across an aplication that needed 40 forms.
If the problem is indeed the number of forms, which you seem to have prooved that it is then the only option is to use less forms
This doesn't mean that you need to lose any functionality though. You will probably need to add forms in runtime and then dispose of them when you've finished with them. This will free up memory, so you can continue with your aplication.

Ps if you can post your code then myself and the others here on the forum may be able to point out a better way of doing it (I'm only an amateur but there's a lot of knowledge around the forum)

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 06:42 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

Small correction, you can't dispose of forms (whether created at runtime or not).
Reply With Quote
  #4 (permalink)  
Old 03-01-2008, 07:52 AM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default

I appreciate the offer, but it's not practical to post the code. One, it's 17,000+ lines long. Two, my employer would probably object to my posting the code.

I expect that you're right - I'm going to have to build at least some of the forms dynamically, preferrably the simpler ones. I just hope I don't run into another memory error as a result of trying to dynamically populate a blank form.


Gary

__________________
PC: Windows XP Pro SP3 / Basic4PPC v6.5
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
  #5 (permalink)  
Old 03-01-2008, 08:04 AM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default One really dumb question...

I'm making a grand assumption that if the mobile device that's having the memory problem simply had more memory, I wouldn't be having this problem.

Since I know very little about how .Net works, I'm cautious about just going out and getting a memory upgrade without knowing.

Is there an upper limit to the amount of memory that .Net will allocate for itself? Or will it use whatever it can up to the limit of available memory?


Gary

__________________
PC: Windows XP Pro SP3 / Basic4PPC v6.5
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
  #6 (permalink)  
Old 03-01-2008, 08:20 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

More memory will probably help but I can't say for sure.
I recommend you to use more Panels or TabControls instead of forms or use the nonoptimized compiler. All libraries (except of agraham's threading library) work with the nonoptimized compiler.
Reply With Quote
  #7 (permalink)  
Old 03-01-2008, 09:44 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by Erel View Post
Small correction, you can't dispose of forms (whether created at runtime or not).
Sorry about that.... think that I may have fallen into this trap before as it is documented in the help as having a dispose method.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #8 (permalink)  
Old 03-01-2008, 09:47 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

The documentation will be fixed.
Reply With Quote
  #9 (permalink)  
Old 03-01-2008, 09:57 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by willisgt View Post
I just can't beleive that this program is chewing up more than 70 megabytes of free program memory and still wanting more.
I believe it is building all the forms on start-up, and 40 VGA size form bitmaps take lots of memory even before controls are added to them! However I don't understand why the non-optimised compiler does not suffer this effect (Erel?)

Quote:
I use about a dozen DLLs, and I'm not sure which ones are protesting in a non-optimized compilation.
What are they protesting about?

EDIT :- Sounds like a truly epic program!

Last edited by agraham : 03-01-2008 at 10:00 AM.
Reply With Quote
  #10 (permalink)  
Old 03-01-2008, 12:18 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

The non-optimised compiler doesn't create real 640 * 480 VGA forms and therefore each form consumes less memory.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Proper use of the .New methods, out of memory error kolbe Questions & Help Needed 5 09-05-2008 02:37 PM
Format Exception Error Zenerdiode Questions & Help Needed 2 09-03-2008 04:12 PM
"Hello World" = 3MB of memory & 6-8 seconds to load yairlanz Questions & Help Needed 8 07-29-2008 11:15 AM
Regional Settings: Error loading program. Exception mtse Bug Reports 0 05-24-2007 02:40 AM
Out of Memory error while loading bitmap HARRY Questions & Help Needed 3 05-15-2007 01:12 PM


All times are GMT. The time now is 02:56 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0