473,396 Members | 1,872 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,396 software developers and data experts.

DIR function Memory Leak

I think I have found a memory leak using the DIR function and also
using the System.IO.File.Exists. Create a new windows application,
place a timer on the form, in the Timar1_Tick event put:

If Dir("C:\SomeFile.txt") = "" then
End If

The "C:\SomeFile.txt" doesn't need to exist. you can also see the same
thing using:
If System.IO.File.Exists("C:\SomeFile.txt") Then
End If

Watch the memory of the process in task manager, and it grows.
Anybody have any thoughts?
Nov 20 '05 #1
2 1340
If you force the garbage collector to do it's thing (GC.Collect()), either
every time (excessive) or every X times, does it still grow?

Jevon
"VBProgrammer" <ta********@dtiibs.com> wrote in message
news:27**************************@posting.google.c om...
I think I have found a memory leak using the DIR function and also
using the System.IO.File.Exists. Create a new windows application,
place a timer on the form, in the Timar1_Tick event put:

If Dir("C:\SomeFile.txt") = "" then
End If

The "C:\SomeFile.txt" doesn't need to exist. you can also see the same
thing using:
If System.IO.File.Exists("C:\SomeFile.txt") Then
End If

Watch the memory of the process in task manager, and it grows.
Anybody have any thoughts?

Nov 20 '05 #2
"VBProgrammer" <ta********@dtiibs.com> schrieb
I think I have found a memory leak using the DIR function and also
using the System.IO.File.Exists. Create a new windows
application, place a timer on the form, in the Timar1_Tick event
put:

If Dir("C:\SomeFile.txt") = "" then
End If

The "C:\SomeFile.txt" doesn't need to exist. you can also see the
same thing using:
If System.IO.File.Exists("C:\SomeFile.txt") Then
End If

Watch the memory of the process in task manager, and it grows.
Anybody have any thoughts?

Welcome to the world of garbage collection! ;-) Dir internally creates
object(s) and releases them but the GC won't collect them and free memory
before it thinks it's the time to do it.
Add
gc.collect
after the dir function call and watch the memory usage now - but just for
testing purposes.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

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

Similar topics

8
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
4
by: Don Nell | last post by:
Hello Why is there a memory leak when this code is executed. for(;;) { ManagementScope scope = new ManagementScope(); scope.Options.Username="username"; scope.Options.Password="password";...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
42
by: Martin Jørgensen | last post by:
Hi, I'm trying to move a matlab program into c language. For those who knows matlab, this is the line I want to program in c: hx(1:nx,1:ny) = 0; % nx=10, ny=10 It works on a 2-dimensional...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
14
by: Nickolay Ponomarev | last post by:
Hi, Why does http://www.jibbering.com/faq/ uses new Function constructor instead of function expressions (function(...) { ... }) when defining new functions? E.g. for LTrim and toFixed. Is the...
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
7
by: Gregor Kofler | last post by:
What is the best practice for removing anonymous functions? Something like (function() { doSomething(); arguments.callee = null; })(); seems to work (at least it triggers no errors or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
tracyyun
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...

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.