Hello!
I access MS Excel using OLE Automation with Ruby.
The problem is that after quitting it, Excel process is still in the memory.
When I did the same thing with Python, it was released.
Is it related to the GC behavior?
(Python uses reference counting method and Ruby uses Mark and Sweep.)
Here's my code:
def get_excel(fn = "", visible = true)
require 'win32ole'
excel = WIN32OLE.new("Excel.application")
excel.visible = visible
if fn != ""
excel.Workbooks.Open(fn)
end
return excel
end
xl = get_excel
....#handles xl
xl.quit #Excel disappears from the screen.
xl = nil #In Python, this GCed Excel completely.
GC.start #Excel seems to go away but the process is still alive when I watch
Task Manager.
Did I do something wrong?
Thanks.
Sam
Sam,
"Sam Sungshik Kong" <ssk@chol.nospam.net> wrote in message
I access MS Excel using OLE Automation with Ruby.
The problem is that after quitting it, Excel process is still in the
memory.
Which version of Ruby are you having ?
When I did the same thing with Python, it was released.
Is it related to the GC behavior?
(Python uses reference counting method and Ruby uses Mark and Sweep.)
Here's my code:
def get_excel(fn = "", visible = true)
require 'win32ole'
excel = WIN32OLE.new("Excel.application")
excel.visible = visible
if fn != ""
excel.Workbooks.Open(fn)
end
return excel
end
xl = get_excel
...#handles xl
xl.quit #Excel disappears from the screen.
xl = nil #In Python, this GCed Excel completely.
GC.start #Excel seems to go away but the process is still alive when I
watch
Task Manager.
Did I do something wrong?
Not that I can see. When I ran this on my machine (Win XP Home, Excel 2002)
using ruby 1.8.2 (2004-06-29) [i386-mswin32] it did as expected. Even
* without * the xl = nil; GC.start
Thanks.
Sam
HTH,
-- shanko
Hi!
Thank you for replying.
I didn't provide enough information.
My ruby is 1.8 and also i386-mswin32.
I narrowed down the problem.
The problem occurs in irb mode only.
If I exit the irb, the Excel process is ended.
How about you?
Sam
"Shashank Date" <sdate@everestkc.net> wrote in message
news:2m3jjeFigtndU1@uni-berlin.de...
Sam,
"Sam Sungshik Kong" <ssk@chol.nospam.net> wrote in message
> I access MS Excel using OLE Automation with Ruby.
> The problem is that after quitting it, Excel process is still in the
memory.
Which version of Ruby are you having ?
> When I did the same thing with Python, it was released.
> Is it related to the GC behavior?
> (Python uses reference counting method and Ruby uses Mark and Sweep.)
>
> Here's my code:
>
> def get_excel(fn = "", visible = true)
> require 'win32ole'
> excel = WIN32OLE.new("Excel.application")
> excel.visible = visible
> if fn != ""
> excel.Workbooks.Open(fn)
> end
> return excel
> end
>
> xl = get_excel
> ...#handles xl
> xl.quit #Excel disappears from the screen.
> xl = nil #In Python, this GCed Excel completely.
> GC.start #Excel seems to go away but the process is still alive when I
watch
> Task Manager.
>
> Did I do something wrong?
Not that I can see. When I ran this on my machine (Win XP Home, Excel
2002)
···
using ruby 1.8.2 (2004-06-29) [i386-mswin32] it did as expected. Even
* without * the xl = nil; GC.start
> Thanks.
>
> Sam
HTH,
-- shanko
"Sam Sungshik Kong" <ssk@chol.nospam.net> wrote in message
The problem occurs in irb mode only.
If I exit the irb, the Excel process is ended.
How about you?
Sam
Yes, I see the same problem with irb. But remember irb does
things differently than the ruby interpreter. I will chalk this up as
one of those differences, unless some experts here have a
better answer/solution.
-- shanko