Solved

'Out of String Space' Error, what to do?

Posted on 2004-09-06
11
8,874 Views
Last Modified: 2012-06-21
I am getting "error 14, Out of string space' from my VB app.  I do have several large tables and forms in the app.  What are the limits of 'string' space in a VB app.  Is it possible to control, expand or even monitor them beyond the task manager memory usage  monitor.

I am running Window XP.  I am not an OS guy but on a very high level I thought that the operating system would aquire wahtever resources it needs to satisfy a given applications memory requirements.  Event to the point of using available hard drive space, which would obviously severely slow down the app but still enable it to run.
0
Comment
Question by:mlcktmguy
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 11

Accepted Solution

by:
bingie earned 45 total points
ID: 11993045
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11993067
Find the line of code causing error and then look at the length of the string using:

Debug.Print Len(sMyString)
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 40 total points
ID: 11993438
Are you reading any large files all at once into a string and then manipulating that string?

If so, you may need to read the file line by line or in chunks.

Idle_Mind
0
 
LVL 2

Expert Comment

by:pelegst
ID: 11993546
By way of explanation: I have heard that VB isn't very good about recovering string space. The example referenced in the article, where it does "MyString = MyString & MyString" in a loop 100 times kills the program demonstrates (apparently) that every time you save the new string, it goes and gets some a new piece of heap space but doesn't seem to recover the old space.
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11994397
pelegst

In bingie's link:

MyString = "Hello"
For Count = 1 To 100
    MyString = MyString & MyString
Next Count

If the computer managed to get to 100, MyString would be 5*(2^100) characters long. It would need more memory to store the string than exisits in the world! It doesn't demonstrate that the old space isn't recovered.
 
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 7

Expert Comment

by:Burbble
ID: 11996722
5,764,607,523,034,234,880 terabytes (plus 10 bytes), to be exact.

Good ol' Microsoft, lol...

From MSDN:

>> There are two kinds of strings: variable-length and fixed-length strings.
>>   A variable-length string can contain up to approximately 2 billion (2^31) characters.
>>   A fixed-length string can contain 1 to approximately 64K (2^16) characters.

-Burbble
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 11997082
Interesting.  How do I define my strings to ensure that they are variable length?  Typically to define a string in a module I use:

Dim VarA as String

I understand that in UDT's I associate with file handling they must be fixed length.  I define those as:

Public Type defstrat
  ECode As String * 7
  ACode As String * 7
  DefStrategy As String * 50
  crlf As String * 2
End Type

Is there more to it than that?  What if I define my Stirngs as variant instead of String?


0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11997133
You are correct:

    Dim VarA as String

would define VarA as a variable length string.

Idle_Mind
0
 
LVL 18

Assisted Solution

by:JR2003
JR2003 earned 40 total points
ID: 11998440
When you have finished with a string you can just put
VarA = ""
This will release the memory from the string.
I sounds to be like might have a bug a bit like Microsoft's example of
Do
  MyString = MyString & MyString
Loop

It might be worth checking you code for this type of error.
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 12005988
I just found out that one of the users that is experiencing the 'Out of String' error is running XP Pro with Service Pack 2 installed.  I do not have Service Pack 2 on any of my machines and the app runs without error.  Does anyone know if Service Pack 2 could be the culprit.  Specifically does it mess with memory management?  I read through the write-ups and didn't see anything in it that should cause an issue with this single user, standalone app.  However I have heard numerous horror stories from those that installed, that's why I have not.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12006023
I am running Win XP Pro w/ SP2 and have not yet encounterd any problems with VB6.  (That doesn't mean it's not the problem though...)

Idle_Mind
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now