Out of Memory error in Visual Basic 6

My Project has 90 forms (MDI-child), 50 standard modules

Here is my system and software info
Win 2000 SP4
Ram - 1 GB
Free Space in Hard Drive - 1.8 GB
Total Paging file size 1024mb (initial) and 1531(Maximum) [bumped it from 768 to 1024]
Visual Studio 6 SP3
VBproject size is nearly 30 MB
Oralce as backend and I use OLE objects to interact with the database.
We use some other third party controls in the VB project (True DBGrid, Sheridan Combobox [not much]) .
I kept all the public constants under the TypeLibraries. I was able to compile the project and can make an EXe successfully until I tried to add the below:

I added couple of new forms (both forms has True DBGrid and command buttons (control Array)), one standard module and a class module (90 lines) which has code related to MSXML4.
I was able to add this to the project, but I am getting "Out of Memory" error right away when I run the project (Run/Start or Run/Start With Full Compile). Well, lot of posts talk about big arrays could be the culprit. But I did not have any big arrays used in my project. I commented all the code in the new forms (two) and module and started removing the comments for little chunk of code and did full compile. Like that I was able to uncomment the code for one form but not for the other. I have a 1mb huge bas file (nearly 26,500 lines). I will start breaking it into multiple modules. I have some big functions which already exists (may be from an year) and if I copy that in a notepad, it comes around 130 kB. Does this exceeding 64kb limit. If so then why it didn't complained earlier. Is there any tool that can tell us about the memory allocation statistics for a VB project [I mean the tool specifying the location where it exceeds the limitation etc..],?
I really have to add the new code. Is there any thing I can do without doing major changes because we really have no time [atleast right now] for the major changes?
I tried this in couple of machines which has more harddrive Free space (60 GB), unfortunately its the same result. Is this relates to any stack space issue? Does any one has ideas?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Yeah I would think it definetly has to relate with the program overrunning it's allocated stack space.  This could be caused by a large array or a recursive function.  Lets try these few steps first.

There is a known issue MSDN Article # 831262 and hotfix if this is the problem this may resolve your error.
1) When get that error, save your project close VB, and then re-open the project and try it again.  

2) Use F8 to single step through the code and see what is raising the error.  Maybe code is overstepping bounds on an array or combo/list box somewhere.  Or go to Tools -> Options -> General and set to break on all errors, then run the project and see what line of code is causing the error.

Unfortunatly VB doesn't support all the nifty memory viewers included with C++, so from the IDE there isn't a way to see the stack and see what's on it when the program crashes.  Pull up Task manager while the program is running and it will show you how much RAM the program is using.

get back with me I want to know what would cause this

CiviAuthor Commented:
I looked at that article [# 831262] and its says about the Active X DLL Project . But my Project is a standard Exe. Any how that article came around october 2003. So which service pack has this bug fix?
>>1. After I got the the error, I closed the project and reopened. Its the same out of memory error. Nothing changed.

>>2. I did changed the settings [Tools -> Options -> General and set to break on all errors] and step through the code. It was throughing error on Space, Chr (I will chaged to Chr$) and an object declared as MaskEditbox [MaskEdit is an input parameter to a public function] and so on. Then I stopped stepping into the code. These are the ones exists from years and why is it giving error now? [may be a stupid question].

>> I looked at the task manager and it was around 38000KB. When I started stepping into the code, it raised almost to double. If I close the EXe the memory is not dallocated. I closed the executable by clicking the close button in the code which unload all the forms. But the task manager show that the memory was not deallocated. I clicked the close button on the log on screen itself. By that time the actual forms now even opended. I have 6 type libraries that has all the public constants (moved all the constants from bas module to a type libraries) in it.
Are these type libraries bumping up the resource usage? Well I moved all these constants to avoid 64KB declaration limit. Any clues?
One of the reason for this error is use of Richtextbox. This error comes when you deploy the wrong version of riched32.dll on the client machine. There are three versions of riched32.dll and of these three versions, one version can't be deployed. These links will tell you the whole story.

Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

CiviAuthor Commented:
I have visual Studio 6 and outlook installed on my machine. Actually all these errors are occuring on my machine [tested on other developer machines too and is the same problem]. We are using RichTextBox in 6 or 7 places to display info [not used much]. But my project is there from years (more than 5) and using the RichTextBox since then. We did not have any problems earlier. And also we used PDW to create the setup.  Any one has clues please ????
Nope...I encountred this problem with Richtextbox only some years back.
Naveen SwamyYash Infinite Solutions Private LimitedCommented:
install sp6 and check for no. of oracle instances
CiviAuthor Commented:
Hi Guys,
At last I found the solution and made it work. We have lot of variant return functions in our project and changed all those to string return functions. This let me do Full compile for the project.

UCase->UCase$, LCase->LCase$, Trim->Trim$, Format->Format$, Mid->Mid$, Left->Left$, Right->Right$, String->String$, Chr->Chr$, Date->Format$(Now, "MM/DD/YYYY"), Space->Space$, Error->Error$, Hex->Hex$, Dir->Dir$

Thank you all for responding to my question/problem.

PAQed with points refunded (500)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.