473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with memory/resource use

Hi,
I'm pretty new to Visual Basic and was wondering if anyone could give
some general advise on how to conserve memory when running a Visual
Basic program that I've created. I keep getting a "Win32 exception was
unhandled" error, and I'm pretty sure resource usage is the problem.
This might be way too general of a question, so I'll try to explain
what it is I'm trying to do as briefly as I can.

Basically, my program reads a text file that's about 30 kb in size, and
about 450 lines long. Each line contains 8 comma delimited variables.
I use the System.IO.StreamReader tool to do this, and read each line
seperately and store each line in a String array. I then create
another array called "variable(7)" (one space for each comma seperated
value). I have a For loop that then changes the text in a combo box
and a number of text boxes to be read later. Looks something like this
(Note: j = total number of lines + approx. 450):

Dim variable(7) As String

For i = 1 To j
variable = Split(ReaderText(i), ",")
cboxSecType.Text = variable(0)
txtMannings.Text = variable(1)
txtLength.Text = variable(2)
txtSlope.Text = variable(3)
txtPeakFlow.Text = variable(4)
txtTimeToPeak.Text = variable(5)
txtNSAVE.Text = variable(6)
Call WriteMultiInput()
ProgressBar.Value = ProgressBar.Value + 1
Next i

The string array variable(7) is only created once, but the values in
variable(7) change as I'd like them to each time through the For loop.
The function Call WriteMultiInput() shown above in the For loop
basically writes and saves a new textfile for each loop using the
variables above plus a number of others, some of which change
automatically depending on the variables that are initially read. Each
of the text files written is pretty small - about 3 to 5 kb in size.
There are a number of other variables that are saved when writing each
new text file.

Overall my program works as I want it to. It runs and writes the text
files exactly as I'd like it to up to a certain point (approximately 50
text files, approx. 3-5 kb per file, total of about 205 kb). But it
stops around 50 and I'd like to get it to the 450 I'm trying to read.

So, I hope that wasn't too long-winded, but if you're still with me,
any thoughts?

Sep 12 '06 #1
4 1095
A couple of thoughts:
In each loop, the text boxes are changed. At the end, you'll have the
final loop values. What is the point of changing them all the way through?

You don't show the initialization of the progress bar - does it allow
for the correct number of lines?

Ignoring that, there doesn't seem to be anyting in this loop that would
cause a problem - maybe the real issue is in WriteMultiInput().

I would recommend putting a try-catch block around the loop, and also in
the WriteMultiInput() method, and put a breakpoint in the catch
statement. Something may show up that way.

Tom

Ja**********@ec.gc.ca wrote:
>Hi,
I'm pretty new to Visual Basic and was wondering if anyone could give
some general advise on how to conserve memory when running a Visual
Basic program that I've created. I keep getting a "Win32 exception was
unhandled" error, and I'm pretty sure resource usage is the problem.
This might be way too general of a question, so I'll try to explain
what it is I'm trying to do as briefly as I can.

Basically, my program reads a text file that's about 30 kb in size, and
about 450 lines long. Each line contains 8 comma delimited variables.
I use the System.IO.StreamReader tool to do this, and read each line
seperately and store each line in a String array. I then create
another array called "variable(7)" (one space for each comma seperated
value). I have a For loop that then changes the text in a combo box
and a number of text boxes to be read later. Looks something like this
(Note: j = total number of lines + approx. 450):

Dim variable(7) As String

For i = 1 To j
variable = Split(ReaderText(i), ",")
cboxSecType.Text = variable(0)
txtMannings.Text = variable(1)
txtLength.Text = variable(2)
txtSlope.Text = variable(3)
txtPeakFlow.Text = variable(4)
txtTimeToPeak.Text = variable(5)
txtNSAVE.Text = variable(6)
Call WriteMultiInput()
ProgressBar.Value = ProgressBar.Value + 1
Next i

The string array variable(7) is only created once, but the values in
variable(7) change as I'd like them to each time through the For loop.
The function Call WriteMultiInput() shown above in the For loop
basically writes and saves a new textfile for each loop using the
variables above plus a number of others, some of which change
automatically depending on the variables that are initially read. Each
of the text files written is pretty small - about 3 to 5 kb in size.
There are a number of other variables that are saved when writing each
new text file.

Overall my program works as I want it to. It runs and writes the text
files exactly as I'd like it to up to a certain point (approximately 50
text files, approx. 3-5 kb per file, total of about 205 kb). But it
stops around 50 and I'd like to get it to the 450 I'm trying to read.

So, I hope that wasn't too long-winded, but if you're still with me,
any thoughts?
Sep 13 '06 #2
Sorry, I initialize the progress bar and set the maximum value before
starting the For loop, I just didn't include it in my post.
Also, the sub WriteMultiInput() is called every time through the For
loop, so the text boxes change every time in the For Loop, and each
time WriteMultiInput() is called, it uses the values in each text box
at that instant of time (ie. during the For loop) to write a new text
file. During the next loop, the values change, WriteMultiInput() is
called again, and it again uses the new values to create another new
text file. That's why they change all the way through. The loop is
supposed to go on until variables from all 450 lines initially read
from the initial text file are used, but for some reason it gets the
Win32 error after 53 loops every time.
Also, WriteMultiInput() is a sub that writes the final text file, but
within this sub there are a number of other subs that are also called,
which output values that are also used in WriteMultiInput() in addition
to those from the For Loop I showed. Note that the Win32 error occurs
in one of these other subs, but again, not until the 53rd time through
the loop.
Boy this must sound confusing, I hope I'm making myself somewhat clear.


tomb wrote:
A couple of thoughts:
In each loop, the text boxes are changed. At the end, you'll have the
final loop values. What is the point of changing them all the way through?

You don't show the initialization of the progress bar - does it allow
for the correct number of lines?

Ignoring that, there doesn't seem to be anyting in this loop that would
cause a problem - maybe the real issue is in WriteMultiInput().

I would recommend putting a try-catch block around the loop, and also in
the WriteMultiInput() method, and put a breakpoint in the catch
statement. Something may show up that way.

Tom

Ja**********@ec.gc.ca wrote:
Hi,
I'm pretty new to Visual Basic and was wondering if anyone could give
some general advise on how to conserve memory when running a Visual
Basic program that I've created. I keep getting a "Win32 exception was
unhandled" error, and I'm pretty sure resource usage is the problem.
This might be way too general of a question, so I'll try to explain
what it is I'm trying to do as briefly as I can.

Basically, my program reads a text file that's about 30 kb in size, and
about 450 lines long. Each line contains 8 comma delimited variables.
I use the System.IO.StreamReader tool to do this, and read each line
seperately and store each line in a String array. I then create
another array called "variable(7)" (one space for each comma seperated
value). I have a For loop that then changes the text in a combo box
and a number of text boxes to be read later. Looks something like this
(Note: j = total number of lines + approx. 450):

Dim variable(7) As String

For i = 1 To j
variable = Split(ReaderText(i), ",")
cboxSecType.Text = variable(0)
txtMannings.Text = variable(1)
txtLength.Text = variable(2)
txtSlope.Text = variable(3)
txtPeakFlow.Text = variable(4)
txtTimeToPeak.Text = variable(5)
txtNSAVE.Text = variable(6)
Call WriteMultiInput()
ProgressBar.Value = ProgressBar.Value + 1
Next i

The string array variable(7) is only created once, but the values in
variable(7) change as I'd like them to each time through the For loop.
The function Call WriteMultiInput() shown above in the For loop
basically writes and saves a new textfile for each loop using the
variables above plus a number of others, some of which change
automatically depending on the variables that are initially read. Each
of the text files written is pretty small - about 3 to 5 kb in size.
There are a number of other variables that are saved when writing each
new text file.

Overall my program works as I want it to. It runs and writes the text
files exactly as I'd like it to up to a certain point (approximately 50
text files, approx. 3-5 kb per file, total of about 205 kb). But it
stops around 50 and I'd like to get it to the 450 I'm trying to read.

So, I hope that wasn't too long-winded, but if you're still with me,
any thoughts?

Sep 13 '06 #3
If the error is in another sub, how can we help without seeing what
those other subs are doing?

T

Ja**********@ec.gc.ca wrote:
>Sorry, I initialize the progress bar and set the maximum value before
starting the For loop, I just didn't include it in my post.
Also, the sub WriteMultiInput() is called every time through the For
loop, so the text boxes change every time in the For Loop, and each
time WriteMultiInput() is called, it uses the values in each text box
at that instant of time (ie. during the For loop) to write a new text
file. During the next loop, the values change, WriteMultiInput() is
called again, and it again uses the new values to create another new
text file. That's why they change all the way through. The loop is
supposed to go on until variables from all 450 lines initially read
from the initial text file are used, but for some reason it gets the
Win32 error after 53 loops every time.
Also, WriteMultiInput() is a sub that writes the final text file, but
within this sub there are a number of other subs that are also called,
which output values that are also used in WriteMultiInput() in addition
to those from the For Loop I showed. Note that the Win32 error occurs
in one of these other subs, but again, not until the 53rd time through
the loop.
Boy this must sound confusing, I hope I'm making myself somewhat clear.


tomb wrote:

>>A couple of thoughts:
In each loop, the text boxes are changed. At the end, you'll have the
final loop values. What is the point of changing them all the way through?

You don't show the initialization of the progress bar - does it allow
for the correct number of lines?

Ignoring that, there doesn't seem to be anyting in this loop that would
cause a problem - maybe the real issue is in WriteMultiInput().

I would recommend putting a try-catch block around the loop, and also in
the WriteMultiInput() method, and put a breakpoint in the catch
statement. Something may show up that way.

Tom

Ja**********@ec.gc.ca wrote:
>>>Hi,
I'm pretty new to Visual Basic and was wondering if anyone could give
some general advise on how to conserve memory when running a Visual
Basic program that I've created. I keep getting a "Win32 exception was
unhandled" error, and I'm pretty sure resource usage is the problem.
This might be way too general of a question, so I'll try to explain
what it is I'm trying to do as briefly as I can.

Basically, my program reads a text file that's about 30 kb in size, and
about 450 lines long. Each line contains 8 comma delimited variables.
I use the System.IO.StreamReader tool to do this, and read each line
seperately and store each line in a String array. I then create
another array called "variable(7)" (one space for each comma seperated
value). I have a For loop that then changes the text in a combo box
and a number of text boxes to be read later. Looks something like this
(Note: j = total number of lines + approx. 450):

Dim variable(7) As String

For i = 1 To j
variable = Split(ReaderText(i), ",")
cboxSecType.Text = variable(0)
txtMannings.Text = variable(1)
txtLength.Text = variable(2)
txtSlope.Text = variable(3)
txtPeakFlow.Text = variable(4)
txtTimeToPeak.Text = variable(5)
txtNSAVE.Text = variable(6)
Call WriteMultiInput()
ProgressBar.Value = ProgressBar.Value + 1
Next i

The string array variable(7) is only created once, but the values in
variable(7) change as I'd like them to each time through the For loop.
The function Call WriteMultiInput() shown above in the For loop
basically writes and saves a new textfile for each loop using the
variables above plus a number of others, some of which change
automatically depending on the variables that are initially read. Each
of the text files written is pretty small - about 3 to 5 kb in size.
There are a number of other variables that are saved when writing each
new text file.

Overall my program works as I want it to. It runs and writes the text
files exactly as I'd like it to up to a certain point (approximately 50
text files, approx. 3-5 kb per file, total of about 205 kb). But it
stops around 50 and I'd like to get it to the 450 I'm trying to read.

So, I hope that wasn't too long-winded, but if you're still with me,
any thoughts?




Sep 14 '06 #4
I have far too much code in far too many subs to post it all online. I
was hoping that from what I have said I'd be able to get some general
information on what might be causing the problem and then be able to
search all my code myself and fix the problem.


tomb wrote:
If the error is in another sub, how can we help without seeing what
those other subs are doing?

T

Ja**********@ec.gc.ca wrote:
Sorry, I initialize the progress bar and set the maximum value before
starting the For loop, I just didn't include it in my post.
Also, the sub WriteMultiInput() is called every time through the For
loop, so the text boxes change every time in the For Loop, and each
time WriteMultiInput() is called, it uses the values in each text box
at that instant of time (ie. during the For loop) to write a new text
file. During the next loop, the values change, WriteMultiInput() is
called again, and it again uses the new values to create another new
text file. That's why they change all the way through. The loop is
supposed to go on until variables from all 450 lines initially read
from the initial text file are used, but for some reason it gets the
Win32 error after 53 loops every time.
Also, WriteMultiInput() is a sub that writes the final text file, but
within this sub there are a number of other subs that are also called,
which output values that are also used in WriteMultiInput() in addition
to those from the For Loop I showed. Note that the Win32 error occurs
in one of these other subs, but again, not until the 53rd time through
the loop.
Boy this must sound confusing, I hope I'm making myself somewhat clear.


tomb wrote:

>A couple of thoughts:
In each loop, the text boxes are changed. At the end, you'll have the
final loop values. What is the point of changing them all the way through?

You don't show the initialization of the progress bar - does it allow
for the correct number of lines?

Ignoring that, there doesn't seem to be anyting in this loop that would
cause a problem - maybe the real issue is in WriteMultiInput().

I would recommend putting a try-catch block around the loop, and also in
the WriteMultiInput() method, and put a breakpoint in the catch
statement. Something may show up that way.

Tom

Ja**********@ec.gc.ca wrote:

Hi,
I'm pretty new to Visual Basic and was wondering if anyone could give
some general advise on how to conserve memory when running a Visual
Basic program that I've created. I keep getting a "Win32 exception was
unhandled" error, and I'm pretty sure resource usage is the problem.
This might be way too general of a question, so I'll try to explain
what it is I'm trying to do as briefly as I can.

Basically, my program reads a text file that's about 30 kb in size, and
about 450 lines long. Each line contains 8 comma delimited variables.
I use the System.IO.StreamReader tool to do this, and read each line
seperately and store each line in a String array. I then create
another array called "variable(7)" (one space for each comma seperated
value). I have a For loop that then changes the text in a combo box
and a number of text boxes to be read later. Looks something like this
(Note: j = total number of lines + approx. 450):

Dim variable(7) As String

For i = 1 To j
variable = Split(ReaderText(i), ",")
cboxSecType.Text = variable(0)
txtMannings.Text = variable(1)
txtLength.Text = variable(2)
txtSlope.Text = variable(3)
txtPeakFlow.Text = variable(4)
txtTimeToPeak.Text = variable(5)
txtNSAVE.Text = variable(6)
Call WriteMultiInput()
ProgressBar.Value = ProgressBar.Value + 1
Next i

The string array variable(7) is only created once, but the values in
variable(7) change as I'd like them to each time through the For loop.
The function Call WriteMultiInput() shown above in the For loop
basically writes and saves a new textfile for each loop using the
variables above plus a number of others, some of which change
automatically depending on the variables that are initially read. Each
of the text files written is pretty small - about 3 to 5 kb in size.
There are a number of other variables that are saved when writing each
new text file.

Overall my program works as I want it to. It runs and writes the text
files exactly as I'd like it to up to a certain point (approximately 50
text files, approx. 3-5 kb per file, total of about 205 kb). But it
stops around 50 and I'd like to get it to the 450 I'm trying to read.

So, I hope that wasn't too long-winded, but if you're still with me,
any thoughts?


Sep 25 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: keredil | last post by:
Hi, Will the memory allocated by malloc get released when program exits? I guess it will since when the program exits, the OS will free all the memory (global, stack, heap) used by this...
2
by: trialproduct2004 | last post by:
Hi all i am having two application which are using database connectivity. In both the application i am filling one large table of database into dataset. When i run first application it will...
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
5
by: cashdeskmac | last post by:
Hi, can anyone explain the difference between a memory resource and a non-memory resource. I have been shown an example of error handling for a non-memory resource (accessing a file) but am not...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
5
by: JoeW | last post by:
Now before I go into detail I just want to say that this is purely for my own benefit and has no real world usage. I remember way back when the tool for *nix systems called forkbomb was created. I...
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
2
by: masayuki.takagi | last post by:
hi all, i want to measure memory usage of my python process on Mac OSX. i tired resource module, but it doesn't work on OSX. how can i get it ? thnx.
3
by: CSharper | last post by:
I have a resource file that i open to write.After writing almost 300MB I call the close method and It failed with out of memory. One thing I learned that, in C#, resource writers doesn't write data...
12
by: David Given | last post by:
I have a situation where I need to be able to allocate chunks on unmapped virtual memory. Because the memory I'm allocating isn't mapped, I can't use a normal memory allocator, as most of them...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.