Hi all,
I have developed a .Net app in MDI format. The problem that I have is that every time I change screens (New Child), the PC CPU PageFile usage increments a little. This happens until out of memory and I get a System.OutOfMem oryException.
Is there something subtle Im missing when opening/closing MDIChild forms?
I have written a sub to check that only 1 child is open at 1 time and close all child forms, before opening another: -
Public Sub CloseForms()
-
-
Dim frm As Form
-
Dim Count As Integer
-
For Each frm In MDIParent1.MdiChildren
-
Count = Count + 1
-
frm.Dispose()
-
Next
-
frm = Nothing
-
Count = Nothing
-
-
End Sub
-
I also force a garbage collection with every child screen change:
System.GC.Colle ct()
I also wrote a sub to dispose of all controls on each screen every time a form closes: -
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
-
Dim FormObject As Control
-
For Each FormObject In Me.Controls
-
FormObject.Dispose()
-
Next
-
End Sub
Basically, I got nothing left in the tank, any suggestions would be well recieved!
2 1238
instead of disposing each control,
if you rather do
it should do the same trick.
however you have put the code in form closing event.
I dont know if it makes any diference compared to if it was put in form_closed event
Plater 7,872
Recognized Expert Expert
The dispose method in a form is overloaded to go through all it's child controls and .dipose() them.
However, this doesn't apply to objects that are not gui controls.
Things like filehandles, io streams, sockets, threads and various other objects.
Those must be disposed/closed/aborted manually.
GC.Collect() will not neccesarily do it for you if there is an open handle to it (sockets,stream s, etc) and threads run until their code exits or you call Abort() to send a ThreadAbortExce ption
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bryan Rickard |
last post by:
I wrote a simple program in VB6 to copy all the files from a directory
on a CD-ROM to my hard disk. There are about 10 files, each about
30MB.
The program uses Get and Put to get data from the CD into a buffer and
then put it into the disk. See code below. It works, but it slows
down drastically before it copies all the files. Windows Task Manager
shows the CPU usage gradually increasing as the files are copied,
until it reaches 100...
|
by: KenH |
last post by:
I have a MDI C# Windows form application that increases its memory
usage about 4k every second - even with all of the child windows
closed.
I have seen other posts about similar problems, frequently described
as memory leaks. Any ideas where to go to determine the problem with
the code would be appreciated
I consider the app fairly simple:
Midi app with four child windows. All windows have timers, either to
display time of day or the...
|
by: marko |
last post by:
Here is my problem.
How can i make a field in a form change to a value 1 every morning when
I turn access on, when the date changes?
And how can i make a button on a form which would open another form and
increase the value of one field by 1. The first value of that field
would be 1(from the morning and increasing through the day) and it
would fill in automatically from the last record and then i would push
that button. It would increase...
|
by: Philip Carnstam |
last post by:
How come .Net applications use so much memory? Every application I compile
uses at least 10 MB of memory, even the ones consisting of only a form and
nothing else. If I minimize them though the memory usage drops to a couple
hundred KB. Why?
Is there anything I should to to prevent this? I have compiled in release
and deactivated all forms of debugging, I think!
Thanks,
Philip
|
by: Dan K. |
last post by:
Hi NG,
first of all i am new to OOP and C# so maybe thats my whole problem :)
i wrote a small timer application, like i did if i was starting with
programming in vb long time ago. the vb application (few years old)
has memory usage around 7.000 K ... my new written C# Application
around 18.000 K. after few operations like minimize to tray and then
reactivate form memory usage rises higher ... i tried to integrate
things like...
| |
by: Andrew Ward |
last post by:
Hi All,
I was wondering if it is possible to use precompiled headers without having
to include a <stdafx.h> or whatever in every source file.
My problem is that I have a project that makes heavy usage of a large third
party library which means after pre-processing each translation unit is
around 1meg in size. There are reasons though why I cannot use the standard
approach to precompiled headers.
What I would like to do is somthing like...
|
by: tlyczko |
last post by:
Hello, I've been reading about this topic, and I've gotten myself more
confused, not less.
We have a single-processor license SQL Server Standard 2005 (xeon 2.8
ghz) with 4 GB RAM in Windows Server 2003 SP1 Standard.
I turned on the /3GB switch in boot.ini but not PAE or AWE, would it be
good to have either one??
servers or databases than we presently have.
|
by: narpet |
last post by:
Hello all...
I'm having a problem moving my swap file to a drive other than my primary drive. Right now I have a 3+ gig pagefile.sys that resides on my C drive. When I try to reconfigure (through the advanced options) it doesn't change.
Here's the weird part... it shows that it is configured to have the page file on the other hard drive, but the actual file still resides on C and I can't delete it (all of this is after a reboot). I even...
|
by: chrispy102 |
last post by:
Hi all,
I have an MDI app developed using vis studio 2005.
The problem I have is that evey time I close a Child form and open another, the CPU PF Usage increments slighty. This happens every time you change child forms until you run out of memory upon which you get a System.OutOfMemoryException.
Is there something subtle I'm missing about dealing with opening/closing MDIChild forms?
I have made sure only 1 child is open at one time and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |