dポイントプレゼントキャンペーン実施中!

vbscriptでファイル名にある文字列を含むファイルを検索し、作成日の最も古いファイルをコピーする処理をしています。
下記環境で動かしているのですが、csrss.exeの使用メモリが増加し続けます。

原因または調査の仕方など教えていただけると幸いです。
システムの都合上、別言語への変更はできないのでどうにか解決したいです。
よろしくお願いいたします。

動作環境: windows2003 std sp1
プログラム:
Const ForReading = 1 'read only
Const ForWriting = 2 'write(overwrite mode)
Const ForAppending = 8 'write(add mode)
kekka =0

Set objFS = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
Set colEnv = objShell.Environment("Process")

strNow = Now
FILE_NAME = "test_J999"
LIST_FILE = "D:\common\" & FILE_NAME & ".log"'use log

Set objText = objFS.OpenTextFile(LIST_FILE, ForAppending, True, 0)
objText.WriteLine strNow & " copy.vbs start"

strSndpath = "D:\common\data\"
strRcvpath = "D:\common\"

strFileName = search()
If objFS.FileExists(strCopyFrom) = False Then
Kekka = 0
WScript.Echo kekka
objText.WriteLine strNow & " copy.vbs end" & " error: " & err.Number & " file: nothing"
objText.Close
Set objShell = Nothing
Set objFS = Nothing
WScript.Quit
End If

objFS.CopyFile strCopyFrom,strCopyTo

IF err.number = 0 Then
kekka = 0
Else
kekka = err.number
End IF

WScript.Echo kekka
objText.WriteLine strNow & " copy.vbs end" & " error: " & err.Number & " file: " & strFileName

objText.Close
Set objShell = Nothing
Set objFS = Nothing


Function search()
On Error Resume Next 'error ignore

Set objApl = Wscript.CreateObject("Shell.Application")
Set folder = objFS.GetFolder(strSndpath)
Set folinfo = objApl.NameSpace(strSndpath)

Mostoldtime = strnow
Totalcnt = folinfo.Items().count+5
Redim File(Totalcnt)
i=0

For each t in File
If Instr(t , FILE_NAME) > 0 then
strfilepath = strSndpath & "\" & t
Set fileinfo = objFS.GetFile(strfilepath)
'serch most old file
If fileinfo.DateCreated < Mostoldtime then
Mostoldtime = fileinfo.DateCreated
Filename = t
End If
End If
Next

Erase File
Set objApl = Nothing
search = (Filename)

End function

A 回答 (1件)

Windows Updateすれば、直るのではないかと思います。


原因はwindows2003sp1の欠点と思います。

参考サイト
http://support.microsoft.com/kb/903722/ja
http://support.microsoft.com/kb/914962/ja

参考URL:http://www.windowsfiles.jp/fairu/csrss.exe.html
    • good
    • 0
この回答へのお礼

max_viiv様
ご回答ありがとうございます。
さっそく検証環境で事象を再現し、sp2にupdateしました。メモリリーク自体がなくなったわけではありませんが、メモリ増加量が減りました。

おそらく複数の要因でメモリリークが起きているようなので
引き続き情報を募集します。

お礼日時:2011/01/24 18:53

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!