[python-win32] Memory Consumption when running Python COM Script

Johan Lindvall johan.lindvall at gmail.com
Mon Aug 28 11:52:50 CEST 2006


> That is not expected.  _make_method_ stores a copy of the method in
> self._builtMethods_ (line 309).  A further __getattr__ for that name should
> locate it.  You may have found a 'bug' (or maybe it should be called an
> un-optimization) when the default method name is used though - what is the
> callstack?

I've set a breakpoint on PyParser_ParseStringFlagsFilename. It gets
called for every iteration of the loop, with the same arguments. For
each call, the process memory usage grows by 4-5 K.

PyTokenizer_FromString
PyParse_ParseStringFlagsFileName
Py_CompileStringFlags
builtin_compile
PyCFunction_Call
PyEval_EvalFrame
PyEval_EvalCodeEx

The arguments for PyParse_ParseStringFlagsFileName are:

s = "def AttValue(self, Attribut=pythoncom.Missing):..return
self._ApplyTypes_(1, 2, (12, 0),((9, 1),), 'AttValue', None,
Attribut....)."
filename = "<COMObject <unknown>>"

This appears to come from line 300 in dynamic.py.

> > Is is possible to use early binding (with the code generated from
> > makepy) in a self-hosted python script?
>
> I'm not sure what you mean by 'self-hosted'.  If you mean py2exe, then that
> tool supports a 'typelibs' attribute which can package and use makepy
> generated files.  Google might help you there, but sadly the examples and
> docs are a little light at the moment.

I mean a self hosted script, running through an inproc ActiveScript
python engine.

This is related to the other question I have with AddTypeLib. The
function doesn't seem to generate any python Code for the actual
methods. I would like to use the complete typelib information (with
method code) in a python script.

I am not really sure how to debug the python com code. I have tried
enabling the debug output in dynamic.py, but I am only getting
incomplete information.

-- 
/Johan.


More information about the Python-win32 mailing list