|
Mitch F. wrote: Note:
The following names are Global Variables:
appSelPath
appSelName
appSelAlt
appSelPos
appSelID
canEnable
beenFound
Nasty....
What makes you think this is leaking memory ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hmm... so even if global variables are handled correctly, they will still cause an extremely large growth in memory consumption? Is there any more efficient way to carry variables from one sub to another?
|
|
|
|
|
I see no reason for this to leak memory. I assume you really mean it uses more memory than you would like. No object in this method can leak memory.
Globals won't leak, they are just a poor design. Yes, you can pass variables as parameters, or use delegates if classes need to communicate when a value changes.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Thanks for the responses.
I've created a quick application (using one textbox and one button) to see if global variables are eating up memory and not releasing it, and that seems to be the case.
<br />
Public Class Form1<br />
Dim globalString As String = ""<br />
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged<br />
globalString = TextBox1.Text<br />
End Sub<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
TextBox1.Text = ""<br />
globalString = Nothing<br />
End Sub<br />
End Class<br />
When I add text to the global variable, the memory starts to get eaten pretty quickly, but when I click the button to set the variable to Nothing, the memory still isn't released, but more memory is taken.
Thanks,
Mitch F
|
|
|
|
|
Well, if that's true, that's one more reason not to use globals. However, I'd be inclined to suggest that your methods of watching memory usage are flawed. Do you watch the memory in the task manager ? That's not really accurate.
Also, when I run this, the extra memory usage is minimal. Also, global is not a global, it's a member variable. To be the .NET equivelant of a global, it would need to be static.
Based on the minimal memory usage in the test I just did, I think you're worried about nothing, and certainly should do some reading regarding how the garbage collector works.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
TaskManager ais about the worst tool you can use to see how much memory your app is using. Why??
This is because TaskManager isn't showing you the memory your app is using. It's showing you how much memory is reserved by the .NET CLR Virtual Machine that is running your app. If your app releases managed memory back to the runtime, the runtime holds onto it (as seen by TaskManager) because it's not being released back to Windows. The runtime holds onto it to fill future requests for memory by your application faster. If Windows needs the memory back, the .NET CLR will release any it memorys it has in reserve back to Windows.
If you really want to see how much memory your app is using, use the Performance Monitor and the .NET CLR counters to monitor your app. Task Manager isn't show you how much memory your app is REALLY using.
|
|
|
|
|
Mitch F. wrote: The following names are Global Variables
No, they are not. There are no global variables in VB.NET.
Mitch F. wrote: my memory usage grows by ~100 kb and doesn't go down, according to Task Manager.
The Task Manager doesn't show how much memory your application uses, it shows how much memory the memory management has allocated. When memory is released back to the memory management, it doesn't get released to the system unless the system needs it.
Mitch F. wrote: Array.Clear(lineData, 0, lineData.Length)
lineData = Nothing
Doing things like that only uses CPU time, it doesn't release any memory earlier.
Clearing the array is pointless. When the array is no longer used, the references that it contains are no longer concidered, so all the strings also counts as unused. Actually, clearing the array will keep it in memory longer than if you didn't.
Setting a reference to Nothing only serves a purpose if you later in the code actually check for that Nothing value. Clearing references for the purpose of releasing memory has no effect at all.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi everyone!!
i have a huge problem and i've been working out this one for a long time now. i need your help..
does anyone knows how am i supposed to set the database connection for access if the target computer (the one i am about to deploy the application) is not connected on the network? i have created some applications and executables before and it had perfectly worked because i am using a database that is stored in a server computer and i just configure the connection string based on the shared folder.
my current project work well with that too but i need to install this application to a laptop which is to be brought anywhere (of course) and is not connected on the network. how am i supposed to do this..? i badly need your help guys...
btw, i am using visual studio .net 2002 and my database is in ms access.
thanks a lot in advance!!!
crookshanks
|
|
|
|
|
If your DB is access, then it's just an MDB file, deploy it with your app.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thanks. i have included the database file in my project. but i dont know how to set the oledbconnection datasource..? i mean, i do not know how to declare the datasource path if my database is included in the project.
pls help.thanks.
crookshanks
|
|
|
|
|
The connection string will just be a path to the file - well, not just that, but it will contain the path to the file. So, you may have to build it in code.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
please help me how i am supposed to do that one.
i need to make a connection to the dataadapter that i am using to access my database. and since the database is included in the project which is stored in my C drive(for example), the path for the connection is in Cdrive also.
my problem is that when i install the application to the target computer, an error occur saying that it can't find the path to the database (since the target computer is not connected to the network)
crookshanks
|
|
|
|
|
crookshanks wrote: an error occur saying that it can't find the path to the database (since the target computer is not connected to the network)
Are you not deploying the database ? You should not keep the files in C drive. Keep it in your application directory and .NET framework provides method to access the current application working directory. So you won't miss the path.
|
|
|
|
|
i have the database included in the project.but i don't get what you mean by "deploying the database". i'm sorry i'm new in vb.net..
and also what you mean by application directory? thanks a lot.
crookshanks
|
|
|
|
|
deploying the database means copying the mdb file onto the target PC
the application directory is the directory in the file system that contains your exe, and presumably your mdb
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I would like to add a button column on each row in datagrid.
How should i do it? I searched the forum from google.
The codes look like this: -
' Set datagrid XP Style Button ColumnStyle for City field
.Add(New DataGridXPButtonColumn(SystemColors.ControlText, SystemColors.Control))
' Also you may set datagrid Button ColumnStyle for City
' field without XP Button Style as the following:
' .Add(New DataGridButtonColumn())
With .Item(3)
.MappingName = "City"
.HeaderText = "City"
.Width = 60
.NullText = String.Empty
End With
But the problem that I'm facing is, i can't add "New DataGridXPButtonColumn" or "New DataGridButtonColumn" in datagridtablestyle.
There is no "datagridbuttoncolum" for me to add.
It's not allow for me to do so. How should i do?
Pls help.....
thanks in advance.
regards,
eunice
|
|
|
|
|
Are you using the DataGrid (.NET 1.0 and 1.1) or the DataGridView (.NET 2.0 and above)??
Google results for "add button to datagridview[^]".
|
|
|
|
|
Hi Dave,
I'm using DataGrid (.net 1.1) version, for vb.net window application.
It doesn't have "DataGridButtonColumn" control.
How can i add the button column in datagrid.
Pls guide me.
Thanks.
|
|
|
|
|
If like me, you have been waiting for a version of Crystal Reports 2008 that integrates with Visual Studio 2008, then the wait is over.
You can download Crystal Reports 2008 Service Pack 0 (yes, zero) from here[^], which includes VS 2008 integration.
Steve Jowett
-------------------------
I may not always be right, but I'm never wrong !
|
|
|
|
|
I have just started working for a company and I am having to learn vb.net.
I have been set a task to write a web app that will check a specified folder periodically for a new file. I was just wondering if you guys had any advice on what areas to concern my studies on?
Thanks in advance,
Aaran
|
|
|
|
|
The following are the namespaces you should research :-
System.IO<br />
System.IO.Directory<br />
System.IO.File
Also have a look at the FileSystemWatcher
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Now my friend, the first thing you should start buying a book in vb.net ,or Download some E-books. and try to Google. they already gave you an answer, but as a Beginner , you might be wonderig what does he means about the text he just sent you, he just mean look for those namespaces and start googling and look for answers your self, Good Programmers try to make a research before start asking people how somethings are done
hoope that helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Aaran Heavey wrote: eb app that will check a specified folder periodically for a new file.
A webapplication(ASP.NET) is having a very short lifetime on the server. And it is initiated by a request. I mean it's can't run in the background and check folder periodically. What you are supposed to do when the folder changes ? You may try windows services.
|
|
|
|
|
From what I gather when a new excel file is found, it's data must be transfered to a SQL server database. I am more accustomed to windows applications but the company seem to do most of their programs as web pages though they only run a few across the web (if that makes sense), the rest are locally ran.
Thanks to everyone for the replies!
modified on Wednesday, March 26, 2008 8:26 AM
|
|
|
|
|
Aaran Heavey wrote: new excel file is found, it's data must be transfered to a SQL server database.
Windows service is the best way to go. Write a windows service which use FileWatcher component and looks for the new file. This service shall open it and send data's to SQL server database. You need to install this windows service on the server where your web application is running.
|
|
|
|