On Jan 12, 2010, at 4:10 PM, Luis L. wrote:
I have tried adding my_object.ole_free calls everywhere, but that has
v) and under which Windows flavor.
Also, if this can be reproducible with any COM object, include a
sample script for us to reproduce in other Windows version and Ruby
version combinations.
Sorry for not providing more details. I actually thought this might be
a “known” issue.
Here’s some code. This is running against 1.8.6-p383 (from
rubyinstaller.org) on Windows XP SP3 plus all the latest patches
(Windows Update runs weekly).
def register_callbacks
event.on_event(‘DataResolved’) do |collection, error|
save collection unless error
@flag1 = false
end
end
def save collection
collection.each do |data|
doc = {
‘field1’ => data.Property1.to_i,
‘field2’ => data.Property2.to_f,
‘field3’ => data.Property3
}
@mongo_collection.insert doc
data.ole_free
end
collection.ole_free
end
def request_data start_date, end_date
@start_date = start_date
@end_date = end_date
@flag1 = true
request = @com.CreateDataRequest
range_start_method = request.ole_method_help ‘RangeStart’
range_end_method = request.ole_method_help ‘RangeEnd’
request._setproperty range_start_method.dispid, [@start_date],
[VT_DATE]
request._setproperty range_end_method.dispid, [@end_date], [VT_DATE]
@com.RequestData request
end
I have a method that makes a function call on the COM object
(#request_data). When the function has data to return, it generates a
“DataResolved” event which triggers my callback which was registered
once at the beginning of execution. The callback calls #save and loops
through the collection and pulls some properties into a hash which
then gets inserted into mongodb. When the collection is exhausted, I
go back to #request_data and make another call on the COM object to
request the next batch.
The collection returned is usually around 30MB. I don’t leak all 30MB
each time through; it leaks a big percentage of it though (30 to 50%).
When Task Manager tells me the ruby.exe process is taking up around
1.4GB, the process just exits.
Unfortunately this application is not available to the general public
so I can’t provide a script for someone to independently verify this.
cr