Problemas de memoria WMI/ASP

Ive created a server monitoring script written in classic ASP (Hosted on IIS 7.5).

It has a main page which uses jQuery to automatically reload the content (updating WMI information) It works great, but seems to have an appetite for memory!

There are 4 pages (Service status for 2 servers, printer status on a main DC and disk usage on the same server) The service status pages update every 10 seconds, the printers every 5 seconds and disk usage every minute.

The script basically works for a few hours, then i get code 500 internal server errors, once checking the IIS logs its because of it being "Out of memory" and look at the processes on the server and WmiPrvSvc.exe (NETWORK SERVICE account) is in the hundreds (500mb) and the ISS worker process (w3wp.exe) is using about 50mb (there are other w3ps.exe processes that are higher)

Once i end them both it kicks back into action… Or if i stop the page/requests for a while (varies between 30 sec and 5 mins) the WmiPrvScs ends and i don't get the problem.

Is there a way to minimise the memory usage or is there a command to properly disconnect / clear the memory?

abajo esta el Conceptos básicos of one of my pages to give you an idea of what's going on...

Gracias, Paul.

    strComputer = "." 
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colListOfServices = objWMIService.ExecQuery("SELECT Caption, Started FROM Win32_Service WHERE StartMode = 'Auto'")

    Set arrServices = Server.CreateObject("System.Collections.ArrayList")

    intServices = colListOfServices.Count

    For Each objService in colListOfServices 
        arrServices.Add objService.Caption & "@" & objService.Started

    Response.Write "<table width=""100%"" class=""tblServices"">" & vbCr
    For Each strService in arrServices
        If InStr(strService, ".NET Framework") = 0 AND InStr(strService, "Sophos Web Intelligence Update") = 0 AND InStr(strService, "Shell Hardware Detection") = 0 Then
            ' Above services, start at system startup and then stop after nothing to do
            arrServiceDetails = Split(strService, "@")
            strServiceName = arrServiceDetails(0)
            strServiceStatus = arrServiceDetails(1)

        End If

    Response.Write "</table>"

    Set objWMIService = Nothing
    Set colListOfServices = Nothing
    Set arrServices = Nothing   

preguntado el 09 de septiembre de 13 a las 23:09

1 Respuestas

Are you calling the above code every 10 seconds? I´m not sure, but i looks like you are creating a new WMI object / connection everytime and that adds up. Instead try to keep the object around instead of recreating it. Something like a SingleTon class to hold the connection.

Also, try making a strongly typed class instead of the WMI query, you can do that by looking at this site: MGMTClassGen

Respondido el 14 de Septiembre de 13 a las 16:09

I thought that it might be that... so initially i had written a VB app to query WMI instead and export to xml files but still get the high memory use with WmiPrvSvc.exe and again stops at about 500mb... I then used the class generated by the MGMTClassGen tool you linked to and i got exatly the same results. Ive now noticed that if i query the services WMI i dont have any troubles but when querying the printers, thats when i get the troubles... Ive also found links on the internet about WMI memory leaks but when trying the hot fixes it says it doesnt apply to the system im using. - rrafluap

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.