Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

How to resolve Memory Problems

I am developing an app with a huge form.  The form presents data based on a one to many realtionship between file 'tamain' and file 'detect'.  The layout of tamain is:

Public Type tamain
  ECode As String * 7
  ACode As String * 7
  txt00 As String * 240
  txt01 As String * 240
  txt02 As String * 240
  txt03 As String * 240
  txt04 As String * 240
  txt05 As String * 240
  txt06 As String * 240
  txt07 As String * 240
  txt08 As String * 240
  txt09 As String * 240
  txt10 As String * 240
  txt11 As String * 240
  Scenario As String * 240
  Target As String * 240
  ThreatAct As String * 240
  conID As String * 7
  ThreatLevel As String * 240
  adversary As String * 240
  AdvDed As String * 240
  AdvTact As String * 240
  AdvWeop As String * 240
  DefStrategy As String * 240
  BigDesc As String * 1000
  RTF As String * 5
  RTF01 As String * 5
  RTF02 As String * 5
End Type

The form has up to 15 tabs, each which hold one record from file 'detect'. The layout of detect is:

Public Type detect
  Eval_ID As String * 7
  DetOpID As String * 7
  DONumber As String * 2
  DOLevel As String * 2
  ShortDesc As String * 30
  LongDesc As String * 240
  TaskTime As String * 5
  DetText As String * 240
  DetRating As String * 10
  DetElement As String * 240
  AssessText As String * 240
  AssessRating As String * 10
  AssessElement As String * 240
  NeutText As String * 240
  NeutRating As String * 10
End Type

The amount of code written to support the editing and processing of the form is also massive. The .frm file for this form is 462kb.

There is not a lot of I/O happening.  Records are read in the beginning, massaged and written back out in the end.  The detect record are stroed in an array while being massaged.

The errors that I get are not consistent. Some times I get the 'VB is shutting down' message, sometimes it shuts down without any message, sometimes I get a 'out of string space message' and sometimes I get a 'shutting down because memory at location xxxxxx cannot be read.  I have tried it on another machine and get the same result.

I am hoping that there are some memory management techniques, functions, buffer settings or anything else that can help.  I realize that this is a large program and form but shouldn't the memory swap back and forth?  Any help would be greatly appreciated.  I have invested quite a bit of time into this for a client.  During development and unit testing I thought I was OK.  Now when the time has come to put it all together it's falling apart.

Avatar of Burbble
Burbble
Flag of United States of America image

What operating system are you running it on (primarily)? Windows 98-based operating systems will have trouble will excessively large forms because of the way they handle graphical resources, and unfortunately nothing can be done about this (grr), aside from using an NT-based operating system.

I believe Visual Basic itself also has some limits, especially on Strings, which is why you are getting the "out of string space" error. Again, I can't think of any way to "fix" this without reworking your code completely (or switching to a different language?).

I'm curious to see what other experts have to say about this too :-)

-Burbble
ASKER CERTIFIED SOLUTION
Avatar of petoskey-001
petoskey-001

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mlcktmguy

ASKER

I am running Windows XP
Avatar of petoskey-001
petoskey-001

Well the out of string space is caused by running out of string space.  You declared your strings as String * 240, String * 10, etc.  

Dim str1 As String * 5

Then these could cause it too...

str1 = "Hello World"  
Text1.Text = "Hello World"
str1 = Text1.Text    

Check how big the DB or user control string is before you put it into your short string.  The other possibility is that your running out of memory.  See if you get the same reslts when you run your program without the IDE / SQL Server / Mozilla / whatever else you have running.  I know on my development machines I can chew threw a gig of ram in no time.
Can't read memory at location X could be failure to allocate memory as well.  Run task manager (Ctrl+Alt+Delete) and watch the memory usage while your program runs.  You could have a memory leak.  Sometimes a timer function or recursive function that eats it, or API calls that keep allocating memory.
what is  SP5 a service pack for?  Do you have a link to it.
The Visual Basic 6.0 SP5 Runtime only link is here...
http://www.microsoft.com/downloads/details.aspx?FamilyID=bf9a24f9-b5c5-48f4-8edd-cdf2d29a79d5&DisplayLang=en

The Visual Studio (VB6, VC6, etc) SP6 is here.  Note that this has more updates for Visual Basic, but has extra stuff too.
http://www.microsoft.com/downloads/details.aspx?FamilyID=a8494edb-2e89-4676-a16a-5c5477cb9713&DisplayLang=en

I can't seem to find the links that show all the bug fixes in each service pack, but it's possible one of those fixed bugs is causing your problem.
I have run this on multiple machines and operating system (2000 Professionals) and still get the same errors.

More info: These are the 2 errors that I'm getting a message box:

The header bar says VB6.EXE - Application Error

The message text is:

"The instruction at "0x77fcc83d" referenced memory at "0x68676948" .  The memory could not be "written"

Click OK to terminate
Click on Cancel to debug the program

When I click OK I see another message box:

The header bar again says VB6.EXE - Application Error put it ipreceded by the 'name of the application"

The message text is:

The instruction at "0x77fcc8e1" referenced memory at "0x68676949".  The memory could not be written.


Thanks for the points.  I thought I had posted this, but I dont see it here.

I looked up the errors you mentioned.  The only thing I could find suggested that the program was running out of memory, or possibly had a bad memory stick.  Since you used two machines, my guess is it was really running out of memory.  I didn't find anything about the specific memory locations or instructions.  Visual Basic doesn't really do well with debugging at the memory level, so I can't suggest what to do about that.  

BTW, what was your final solution?