There's your first mistake. Task Manager is not showing you how much memory your application is using, but how much the .NET CLR has RESERVED for your application. Use the .NET Memory counters in PerfMon to find out how much memory your app is actually using.
By reserved, I mean your application can free memory that it isn't using any more but that memory goes back the Managed Heap for future allocations. It will not be freed back to Windows unless the CLR deems that it doesn't need the memory or Windows starts to run low on memory and requests that the .NET CLR frees up whatever it can.
The is a completely automatic process and the .NET Memory Manager does it's job very well. You do not need to worry about freeing up the memory yourself.
Next, this depends on what you're using to show the second form. If you use the .ShowDialog() method on your form instance you MUST call Dispose() method on the form instance when you're done with the form. If you don't do this you WILL run into memory and handle issues, possibly running Windows out of resources.
Oh, and do NOT call GC.Collect() unless you know exactly why you're doing it and understand completely the impacts on the GC. You can easily negatively impact the performance of your application by calling Collect unnecessarily.
You need a totally different architecture.
In the local network, install a proxy server. Setup the network such that all computers have to use the proxy server to reach addresses outside the LAN.
In the proxy server, enable logging. Now you only need an application for reading and analysing that log file.
I am working on a .Net application that needs to access the AS400 for some real-time and iDB2Connection is slow accessing DB2. any idea how can I improve it?
My connection string:
Dim connection As iDB2Connection = New iDB2Connection("DataSource=" & My.Settings.Server & ";" & _
"userID=" & My.Settings.ServiceID & ";" & _
"password=" & My.Settings.ServiceIDPass & ";" & _
"DefaultCollection=" & My.Settings.Library & ";" & _
"SSL=" & "False" & ";")
A "long" execution time for your query can have multiple causes. How big is each record? What speed is the network? I'm starting with these, as it seems to be the load-time that's your biggest bottleneck.
Can you show us how you load your data?
Have you tried comparing it to other compatible providers? (is ODBC available there?)
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
If you are finding that actually establishing the connection, in the first instance, is slow, this is quite common with most databases. The way to get round this is to use a connection pool where inactive connections are stored ready for use again.