Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2004, 03:19 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default I can't create a lot of array on VB

Dear all

Please help me, I have to create a lot of array of string on VB but I can't create it, the VB return the error that "out of memory", but I have 2 GB ram that it's enough to. Please help me how to create a lof of array. Thank you for your help

Best regard
tumarha
 
Old February 28th, 2004, 05:27 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

how long is the array

Ahmed Ali
Software Developer
 
Old March 1st, 2004, 07:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem with re-dimensional arrays in VB is that when you first use them a block of memory will be allocated for it, then when you re-dimension the array the system will try to increase the size of the block of memory and will not use a new block of memory if you want to preserve the data already in the array. If the block of memory can not be increased to the size you require because there is another block of memory in the way, then you will get an out of memory error. Even though there is enough free physical memory, the block of memory being used can not be increased to the size you require.

First of all, are you re-dimensioning the array a lot? If at all possible re-dimension the array as infrequently as you can. What I will often try to do if I am increasing the size of an array in a loop for example, is to increase it by more than I need, then as the loop continues I will use the spare elements of the array instead of re-dimming the array again and again. Then if and when I reach the end of the array and still want to add more data I will re-dim it again by more than I need.

Secondly, can you use a static array? A static array will be much friendlier to your application, improving both performance and memory usage. This is because when your application starts the system will know how much memory is required for the array and it will know that it will never need to change this memory allocation.

Regards
Owain Williams
 
Old March 1st, 2004, 02:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Tumarha,

even if you have 10Gig of memory VB cannot use all of it, because VB, as any other programming languages, has its limitations. Please refer to the "Visual Basic Specifications, Limitations, and File Formats" section of the MSDN VB documentation.
Because of this, the code must catch and handle the 'out of memory' error. Keep in mind that using too much memory will snail the computer: memory usage (especially when processing lot of data) should be the first requirement when designing an application.

Marco


Quote:
quote:Originally posted by tumarha
 Dear all

Please help me, I have to create a lot of array of string on VB but I can't create it, the VB return the error that "out of memory", but I have 2 GB ram that it's enough to. Please help me how to create a lof of array. Thank you for your help

Best regard
tumarha
 
Old March 1st, 2004, 02:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi dear..

another idea.. i dont think any application with your requirements fits in VB.. maybe you need another language to do it??
anyway.. post more info about what are you trying to achieve.. maybe you are handling it in the wrong data structure...

Gonzalo Bianchi
 
Old March 1st, 2004, 03:12 PM
Authorized User
 
Join Date: Jul 2003
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi.
What OS you are using?
I use to have similar problem with VB6 and Windows 98. My array size was ~ 700 MB and 512 RAM. The error disappeared after moving to Win 2000 and XP. Don’t know why.

Pavel


 
Old March 2nd, 2004, 05:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The error disapeared because the virtual memory handling in Windows 2K and XP is much better than it is in 9x. Why on earth would you need an array that is 700Mb in size? As Gonzalo said
Quote:
quote:i dont think any application with your requirements fits in VB.. maybe you need another language to do it
VB is a rapid development tool, not a data cruncher.

Regards
Owain Williams
 
Old May 14th, 2004, 01:20 PM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using VB with large arrays as well. I have a machine running vb6.0 with 2GB. It can't seem to dimension an array (using redim) any larger than 508MB. Anyone have any idea why this might be? The ram is configues as 4 512MB chips. Does this have anything to do with it, or does the physical separation of RAM not matter in terms of contiguousness.

 
Old May 14th, 2004, 01:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi all...
did you read all the thread??
why in the earth you have such array???

HTH

Gonzalo
 
Old May 17th, 2004, 06:02 AM
Authorized User
 
Join Date: Apr 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It has been already mentioned that VB is not the best language for this work. But you may do so-so if you use the byte() type instead of string. But definitelly, you shuld use C++ and do all the memory allocation manually.

webdesign





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB 6.0 & Crystal Report 8.5 - Lot of Problems Anup Gavate VB Components 3 June 5th, 2013 01:54 AM
Create array from database Lofa PHP Databases 1 November 14th, 2006 07:56 PM
create array for loop in FSO jfergy Classic ASP Professional 4 April 14th, 2006 09:59 PM
Can we Create Control Array in ASP.NET? whiterainbow BOOK: Professional Crystal Reports for VS.NET 0 May 6th, 2005 04:24 AM
I can't create array more than 500000 records. tumarha Pro VB Databases 2 March 1st, 2004 09:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.