Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

closing object - removing from memory

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 03-30-2007   #1 (permalink)
Neil Chambers
Guest


 

closing object - removing from memory

PoSH crew,

How can I cleanly close an object and remove it from memory? I've been
reading most of the day and trying things but I can't figure it out (I can
use get-process/stop-process, but there must be a friendlier way).

Specifically I am creating a Excel object:

>$xl = new-object -com excel.application


How can I close this object and clear it from memory?

>$xl.quit()


does nothin'

Cheers,
Neil


My System SpecsSystem Spec
Old 03-30-2007   #2 (permalink)
Neil Chambers
Guest


 

Re: closing object - removing from memory

actually, Klumsy on #powershell pointed out to me that the object had
actually ended but a couple of things can be done to speed up recovery:

1 - nuke the variable
>del variable:\xl


2 - Invoke the Garbage Collector

[gc]::Collect()


:-)
"Neil Chambers" <nospamplease@nospam.com> wrote in message
news:EA2BA9DE-300A-4D30-8CB6-10D896414991@microsoft.com...
> PoSH crew,
>
> How can I cleanly close an object and remove it from memory? I've been
> reading most of the day and trying things but I can't figure it out (I can
> use get-process/stop-process, but there must be a friendlier way).
>
> Specifically I am creating a Excel object:
>
>>$xl = new-object -com excel.application

>
> How can I close this object and clear it from memory?
>
>>$xl.quit()

>
> does nothin'
>
> Cheers,
> Neil


My System SpecsSystem Spec
Old 03-30-2007   #3 (permalink)
RichS
Guest


 

Re: closing object - removing from memory

Many objects have a Dispose() method

--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Neil Chambers" wrote:

> actually, Klumsy on #powershell pointed out to me that the object had
> actually ended but a couple of things can be done to speed up recovery:
>
> 1 - nuke the variable
> >del variable:\xl

>
> 2 - Invoke the Garbage Collector
>
> [gc]::Collect()
>
>
> :-)
> "Neil Chambers" <nospamplease@nospam.com> wrote in message
> news:EA2BA9DE-300A-4D30-8CB6-10D896414991@microsoft.com...
> > PoSH crew,
> >
> > How can I cleanly close an object and remove it from memory? I've been
> > reading most of the day and trying things but I can't figure it out (I can
> > use get-process/stop-process, but there must be a friendlier way).
> >
> > Specifically I am creating a Excel object:
> >
> >>$xl = new-object -com excel.application

> >
> > How can I close this object and clear it from memory?
> >
> >>$xl.quit()

> >
> > does nothin'
> >
> > Cheers,
> > Neil

>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
datalist -- Object reference not set to an instance of an object. Deere .NET General 0 08-31-2008 09:09 AM
Windows Mail keeps closing because DEP is closing for security Window Mail DEP message Vista mail 7 05-23-2007 05:59 AM
Testing object arrays using Compare-Object and -contains Alex K. Angelopoulos [MVP] PowerShell 2 08-31-2006 05:57 PM
Adding canonical aliases for Compare-Object, Measure-Object, New-Object Alex K. Angelopoulos [MVP] PowerShell 2 05-26-2006 07:58 AM


Update your Vista Drivers Update Your Vista Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008
Page generated in 0.35334 seconds with 10 queries