Re: [IronPython] Debugging support PythonEngine
Are there plans to improve the debugging experience in the future or are you at a point where it is “as good as it gets”? Being able to debug makes writing and using python scripts a lot easier. Inside functions I can see not only the function parameters but also the newly defined local variables. Are these different from the global variables? I would have expected that the function locals are also stored inside a dictionary. Is it possible to step into python functions without getting into assembly instructions? This is very frustrating and degrades the debugging experience a lot. This is the more important issue for me. I’m not going to be using global variables frequently, but mostly functions loaded in the PythonEngine that are called from C#. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shri Borde Sent: Friday 11 August 2006 0:30 To: Discussion of IronPython Cc: Glenn Hackney Subject: Re: [IronPython] Debugging support PythonEngine If EngineOptions.ClrDebuggingEnabled is set, we use AssemblyBuilder, TypeBuilder, etc for PythonEngine.Executed. The code generated by AssemblyBuilder, TypeBuilder, etc supports PDB debug information tracking for the methods, and so you will be able to set breakpoints in the code. However, it does not guarantee a perfect debugging experience. PythonEngine.ExecuteFile will use a dictionary for storing global variables, and these will not be visible because VS does not know about the dictionary. If you use PythonEngine.CreateOptimizedModule, most global variables are implemented using CLR statics, and so VS may be able to display them for you. Global variables added using an exec statement will still not be visible. If EngineOptions.ClrDebuggingEnabled is false, we will use System.Reflection.Emit.DynamicMethod. This does not support debug information tracking at all, and you will not even be able to see function variables. So If EngineOptions.ClrDebuggingEnabled is will improve your debugging experience, but it wont give you a perfect experience. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kristof Wagemans Sent: Thursday, August 10, 2006 2:10 PM To: Discussion of IronPython Subject: [IronPython] Debugging support PythonEngine I have been experimenting with the debugging support for the PythonEngine. When I use the following code I have several problems. PythonEngine _pe; EngineOptions options = new EngineOptions(); options.ClrDebuggingEnabled = true; _pe = new PythonEngine(options); _pe.ExecuteFile(@"
Re: [IronPython] PythonEngine.RunFile
Thank you both. I will give that a shot.On 8/10/06, Shri Borde <[EMAIL PROTECTED]> wrote: __name___ == "__main__": is a convention enforced by ipy.exe. The PythonEngine itself does not directly support this concept. However, you can achieve that result (just like ipy.exe does) by using code like this: PythonEngine engine = new PythonEngine(); EngineModule module = engine.CreateModule("__main__", false); engine.ExecuteFile(filename, module); Do you want to help develop Dynamic languages on CLR? ( http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Martin Maly Sent: Thursday, August 10, 2006 3:06 PM To: Discussion of IronPython Subject: Re: [IronPython] PythonEngine.RunFile You can try the PythonEngine.CreateOptimizedModule which you can also pass a name your module should get. Let us know if that doesn't meet your needs. Martin From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 2:17 PM To: Discussion of IronPython Subject: Re: [IronPython] PythonEngine.RunFile I've tested that and I don't think it works with: if __name___ == "__main__": in the python script. Regards, Tim Riley On 8/10/06, Martin Maly <[EMAIL PROTECTED]> wrote: Think PythonEngine.ExecuteFile may work for you. From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Tim Riley Sent: Thursday, August 10, 2006 1:01 PM To: Discussion of IronPython Subject: [IronPython] PythonEngine.RunFile In IP version 0.9 there was a PythonEngine.RunFile() method, this seems to be gone in 1.0.6. Is there a replacement? ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___users mailing listusers@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Embedded IP eating memory
Hi I have an IP-Embedded C# application (IP version IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42, Yeah i know, im out of date, but i havent make the change to latest version because i saw there were some API changes :) ), i create one PyEngine, set some global variables and inside a while block i execute this little script every time: import sys try: i = sys.path.index("scripts")except: sys.path.append("scripts") import CMOpFuncionalidad try: pyop = CMOpFuncionalidad.PyOperador(cmop, dba, connID) pyop.atiendeCM() pyop.liberaRecursosBD() pyop = Noneexcept: pyop.liberaRecursosBD() pyop = None raise The module CMOpFuncionaliad is an IPython script i wrote, it contains a class definition. Inside the scripts i use components defined in some assemblies i made (these are already loaded into the CLR). The problem is, after the Engine takes the usual 12M+- of memory it needs, every time the script executes it consumes 2M more, i dont have a clue why is this...Does this version of IP have memory problems ? Or what else could be ?? If you need to see CMOpFuncionalidad.py let me know and ill send it Thanks for your help Greetings... ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Debugging support PythonEngine
Yes, we will definitely be working on improving the debugging support as it is a critical part of the development process. However, full support will need work in all parts of the tool chain including VS. Python local variables are implemented as normal MSIL variables (except in cases like closures). Hence, VS is able to display them. Currently, the best way to debug Python functions in VS while using PythonEngine would be to enable EngineOptions.ClrDebuggingEnable, open the PY file in VS and put a breakpoint where you want. Stepping in and out of Python functions will step you through methods in IronPython.dll . From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kristof Wagemans Sent: Friday, August 11, 2006 12:36 AM To: 'Discussion of IronPython' Subject: Re: [IronPython] Debugging support PythonEngine Are there plans to improve the debugging experience in the future or are you at a point where it is “as good as it gets”? Being able to debug makes writing and using python scripts a lot easier. Inside functions I can see not only the function parameters but also the newly defined local variables. Are these different from the global variables? I would have expected that the function locals are also stored inside a dictionary. Is it possible to step into python functions without getting into assembly instructions? This is very frustrating and degrades the debugging experience a lot. This is the more important issue for me. I’m not going to be using global variables frequently, but mostly functions loaded in the PythonEngine that are called from C#. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Shri Borde Sent: Friday 11 August 2006 0:30 To: Discussion of IronPython Cc: Glenn Hackney Subject: Re: [IronPython] Debugging support PythonEngine If EngineOptions.ClrDebuggingEnabled is set, we use AssemblyBuilder, TypeBuilder, etc for PythonEngine.Executed. The code generated by AssemblyBuilder, TypeBuilder, etc supports PDB debug information tracking for the methods, and so you will be able to set breakpoints in the code. However, it does not guarantee a perfect debugging experience. PythonEngine.ExecuteFile will use a dictionary for storing global variables, and these will not be visible because VS does not know about the dictionary. If you use PythonEngine.CreateOptimizedModule, most global variables are implemented using CLR statics, and so VS may be able to display them for you. Global variables added using an exec statement will still not be visible. If EngineOptions.ClrDebuggingEnabled is false, we will use System.Reflection.Emit.DynamicMethod. This does not support debug information tracking at all, and you will not even be able to see function variables. So If EngineOptions.ClrDebuggingEnabled is will improve your debugging experience, but it wont give you a perfect experience. Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038) From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kristof Wagemans Sent: Thursday, August 10, 2006 2:10 PM To: Discussion of IronPython Subject: [IronPython] Debugging support PythonEngine I have been experimenting with the debugging support for the PythonEngine. When I use the following code I have several problems. PythonEngine _pe; EngineOptions options = new EngineOptions(); options.ClrDebuggingEnabled = true; _pe = new PythonEngine(options); _pe.ExecuteFile(@"
[IronPython] Need help using IronPython from C#
I'd like to do the equivalent of something like... import RemoteAdmin ls = RemoteAdmin.ConnectToService("localhost","LogViewer") numEntries = ls.GetNumberOfEntries() e = ls.GetEntry(numEntries - 1) entryString = str(e) in C#. So I get as far as PythonEngine e = new PythonEngine(); # The RemoteAdmin module is in an assembly built using IronPython.Hosting.Compiler and then referenced by the C# project ClrModule clr = (ClrModule) e.Import("clr"); clr.AddReference(typeof(RemoteAdmin).Assembly) e.Import("RemoteAdmin"); and then I'm lost. Is there a way to make a delegate from a method that exists in the PythonEngine environment and then call the delegate from C#? I'm aware of the Evaluate and Execute methods of PythonEngine, but I'm looking for a more direct way to call the python methods and access python object attributes, rather than building up strings to pass to Evaluate. Thanks - Jason ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Embedded IP eating memory
How are you executing the script file? If you’re creating a new optimized module each time we won’t be able to collection the optimized module code. If on the other hand you’re just compiling it as a helper method then when it’s done running we can collect the code. In pre-RC1 we had a leak where creating a new PythonEngine would result in a leak of a SystemState and ClrModule which were being hung onto by an event rooted in the app domain. So if you’re re-creating the engine each time you might be seeing that. Also, now that I’ve mentioned events, you might want to check your own C# code if you’re using events: It’s easy to forget to unhook one and leak memory because the event handler stays alive forever. If none of those turn out to be the problem an option here would be to download the free CLR Profiler and look at the object type that is consuming the increased memory. It’ll give you a nice graphical display w/ a block view of what’s referencing what. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodolfo Conde Sent: Friday, August 11, 2006 12:58 PM To: Discussion of IronPython Subject: [IronPython] Embedded IP eating memory Hi I have an IP-Embedded C# application (IP version IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42, Yeah i know, im out of date, but i havent make the change to latest version because i saw there were some API changes :) ), i create one PyEngine, set some global variables and inside a while block i execute this little script every time: import sys try: i = sys.path.index("scripts") except: sys.path.append("scripts") import CMOpFuncionalidad try: pyop = CMOpFuncionalidad.PyOperador(cmop, dba, connID) pyop.atiendeCM() pyop.liberaRecursosBD() pyop = None except: pyop.liberaRecursosBD() pyop = None raise The module CMOpFuncionaliad is an IPython script i wrote, it contains a class definition. Inside the scripts i use components defined in some assemblies i made (these are already loaded into the CLR). The problem is, after the Engine takes the usual 12M+- of memory it needs, every time the script executes it consumes 2M more, i dont have a clue why is this...Does this version of IP have memory problems ? Or what else could be ?? If you need to see CMOpFuncionalidad.py let me know and ill send it Thanks for your help Greetings... ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Need help using IronPython from C#
What you're probably looking for is the CreateMethod method that hangs off of the PythonEngine. Using this you can do: delegate string GetEntryString(); GetEntryString es = engine.CreateMethod(@"import RemoteAdmin ls = RemoteAdmin.ConnectToService('localhost','LogViewer') numEntries = ls.GetNumberOfEntries() e = ls.GetEntry(numEntries - 1) entryString = str(e) return entryString"); Console.WriteLine(es()); If you really do want to get a delegate to a Python function that came from a module you might want to look at Ops.GetDelegate. If you were to create a module, execute its contents, and then get the method back out by name as an object you could pass the method to Ops.GetDelegate w/ a delegate type and create a delegate to the raw Python method that you could call from C#. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Ferrara Sent: Friday, August 11, 2006 12:08 PM To: Discussion of IronPython Subject: [IronPython] Need help using IronPython from C# I'd like to do the equivalent of something like... import RemoteAdmin ls = RemoteAdmin.ConnectToService("localhost","LogViewer") numEntries = ls.GetNumberOfEntries() e = ls.GetEntry(numEntries - 1) entryString = str(e) in C#. So I get as far as PythonEngine e = new PythonEngine(); # The RemoteAdmin module is in an assembly built using IronPython.Hosting.Compiler and then referenced by the C# project ClrModule clr = (ClrModule) e.Import("clr"); clr.AddReference(typeof(RemoteAdmin).Assembly) e.Import("RemoteAdmin"); and then I'm lost. Is there a way to make a delegate from a method that exists in the PythonEngine environment and then call the delegate from C#? I'm aware of the Evaluate and Execute methods of PythonEngine, but I'm looking for a more direct way to call the python methods and access python object attributes, rather than building up strings to pass to Evaluate. Thanks - Jason ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Need help using IronPython from C#
On Aug 11, 2006, at 3:53 PM, Dino Viehland wrote: > > > If you really do want to get a delegate to a Python function that > came from a module you might want to look at Ops.GetDelegate. If > you were to create a module, execute its contents, and then get the > method back out by name as an object you could pass the method to > Ops.GetDelegate w/ a delegate type and create a delegate to the raw > Python method that you could call from C#. I think this is closer to what I want. I'm looking for clean way to expose an API written in Python to a C# program. So I can do MyDelegate ConnectToService = (MyDelegate) IronPython.Runtime.Operations.Ops.GetDelegate(e.Evaluate ("RemoteAdmin.ConnectToService"), typeof(MyDelegate)); and then... object ls = ConnectToService("localhost","LogViewer"); but now how do I get to the methods and attributes of ls? > > -Original Message- > From: [EMAIL PROTECTED] [mailto:users- > [EMAIL PROTECTED] On Behalf Of Jason Ferrara > Sent: Friday, August 11, 2006 12:08 PM > To: Discussion of IronPython > Subject: [IronPython] Need help using IronPython from C# > > I'd like to do the equivalent of something like... > > import RemoteAdmin > > ls = RemoteAdmin.ConnectToService("localhost","LogViewer") > numEntries = ls.GetNumberOfEntries() > e = ls.GetEntry(numEntries - 1) > entryString = str(e) > > > in C#. > > So I get as far as > > PythonEngine e = new PythonEngine(); > # The RemoteAdmin module is in an assembly built using > IronPython.Hosting.Compiler and then referenced by the C# project > ClrModule clr = (ClrModule) e.Import("clr"); > clr.AddReference(typeof(RemoteAdmin).Assembly) > e.Import("RemoteAdmin"); > > and then I'm lost. > > Is there a way to make a delegate from a method that exists in the > PythonEngine environment and then call the delegate from C#? > > I'm aware of the Evaluate and Execute methods of PythonEngine, but > I'm looking for a more direct way to call the python methods and > access python object attributes, rather than building up strings to > pass to Evaluate. > > Thanks > > - Jason > > > ___ > users mailing list > users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > ___ > users mailing list > users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Need help using IronPython from C#
You're quickly getting into the guts of the runtime, so you'll find most of what you want over in Ops. To get an attribute off of an object you can do TryGetAttr(object o, SymbolId name, out object ret). o would be your ls, SymbolId's our what we use internally to represent attributes - you can get one by doing SymbolTable.SymbolToId("foo"), and then we'll pass you out the value. As you get the values back you'd need to re-create delegates to them. Note if you're re-creating delegates of the same type we won't need to do any additional code gen work - we'll just bind the new object back to the existing method we created, so this shouldn't be too nasty to do. If you're getting a property we'll return the property value from Ops.GetAttr (basically if you hit a descriptor we will run the descriptor code for you). And if you're getting some plain old attribute back out then you can do whatever you want w/ the value from there. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Ferrara Sent: Friday, August 11, 2006 1:29 PM To: Discussion of IronPython Subject: Re: [IronPython] Need help using IronPython from C# On Aug 11, 2006, at 3:53 PM, Dino Viehland wrote: > > > If you really do want to get a delegate to a Python function that came > from a module you might want to look at Ops.GetDelegate. If you were > to create a module, execute its contents, and then get the method back > out by name as an object you could pass the method to Ops.GetDelegate > w/ a delegate type and create a delegate to the raw Python method that > you could call from C#. I think this is closer to what I want. I'm looking for clean way to expose an API written in Python to a C# program. So I can do MyDelegate ConnectToService = (MyDelegate) IronPython.Runtime.Operations.Ops.GetDelegate(e.Evaluate ("RemoteAdmin.ConnectToService"), typeof(MyDelegate)); and then... object ls = ConnectToService("localhost","LogViewer"); but now how do I get to the methods and attributes of ls? > > -Original Message- > From: [EMAIL PROTECTED] [mailto:users- > [EMAIL PROTECTED] On Behalf Of Jason Ferrara > Sent: Friday, August 11, 2006 12:08 PM > To: Discussion of IronPython > Subject: [IronPython] Need help using IronPython from C# > > I'd like to do the equivalent of something like... > > import RemoteAdmin > > ls = RemoteAdmin.ConnectToService("localhost","LogViewer") > numEntries = ls.GetNumberOfEntries() > e = ls.GetEntry(numEntries - 1) > entryString = str(e) > > > in C#. > > So I get as far as > > PythonEngine e = new PythonEngine(); > # The RemoteAdmin module is in an assembly built using > IronPython.Hosting.Compiler and then referenced by the C# project > ClrModule clr = (ClrModule) e.Import("clr"); > clr.AddReference(typeof(RemoteAdmin).Assembly) > e.Import("RemoteAdmin"); > > and then I'm lost. > > Is there a way to make a delegate from a method that exists in the > PythonEngine environment and then call the delegate from C#? > > I'm aware of the Evaluate and Execute methods of PythonEngine, but I'm > looking for a more direct way to call the python methods and access > python object attributes, rather than building up strings to pass to > Evaluate. > > Thanks > > - Jason > > > ___ > users mailing list > users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > ___ > users mailing list > users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Embedded IP eating memory
Inside the while cycle, i just do this: pyEngine.RunFile("scripts/CMOpAtiendeCM.py"); thats the little script file. The engine is created only once. However, i did inside the cycle a Console.WriteLine("{0} bytes", System.GC.GetTotalMemory(true)) and it gives lower memory usage, there i see that IP seems to be consuming each time the file is run only 2k, no 2m, as the windows taskmanager says I do use events, but i do remove the handlers when no longer in use... Where can i get a free CLR profiler ?? :)... thanks for the help... Greetings - Original Message - From: Dino Viehland To: Discussion of IronPython Sent: Friday, August 11, 2006 1:48 PM Subject: Re: [IronPython] Embedded IP eating memory How are you executing the script file? If youre creating a new optimized module each time we wont be able to collection the optimized module code. If on the other hand youre just compiling it as a helper method then when its done running we can collect the code. In pre-RC1 we had a leak where creating a new PythonEngine would result in a leak of a SystemState and ClrModule which were being hung onto by an event rooted in the app domain. So if youre re-creating the engine each time you might be seeing that. Also, now that Ive mentioned events, you might want to check your own C# code if youre using events: Its easy to forget to unhook one and leak memory because the event handler stays alive forever. If none of those turn out to be the problem an option here would be to download the free CLR Profiler and look at the object type that is consuming the increased memory. Itll give you a nice graphical display w/ a block view of whats referencing what. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodolfo CondeSent: Friday, August 11, 2006 12:58 PMTo: Discussion of IronPythonSubject: [IronPython] Embedded IP eating memory Hi I have an IP-Embedded C# application (IP version IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42, Yeah i know, im out of date, but i havent make the change to latest version because i saw there were some API changes :) ), i create one PyEngine, set some global variables and inside a while block i execute this little script every time: import sys try: i = sys.path.index("scripts")except: sys.path.append("scripts") import CMOpFuncionalidad try: pyop = CMOpFuncionalidad.PyOperador(cmop, dba, connID) pyop.atiendeCM() pyop.liberaRecursosBD() pyop = Noneexcept: pyop.liberaRecursosBD() pyop = None raise The module CMOpFuncionaliad is an IPython script i wrote, it contains a class definition. Inside the scripts i use components defined in some assemblies i made (these are already loaded into the CLR). The problem is, after the Engine takes the usual 12M+- of memory it needs, every time the script executes it consumes 2M more, i dont have a clue why is this...Does this version of IP have memory problems ? Or what else could be ?? If you need to see CMOpFuncionalidad.py let me know and ill send it Thanks for your help Greetings... __ Información de NOD32, revisión 1.1703 (20060811) __Este mensaje ha sido analizado con NOD32 antivirus systemhttp://www.nod32.com ___users mailing listusers@lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com__ Información de NOD32, revisión 1.1703 (20060811) __Este mensaje ha sido analizado con NOD32 antivirus systemhttp://www.nod32.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Embedded IP eating memory
PS. The module the script loads with import (CMOpFuncionalidad.py) has 15 global-module variables, but with import the module loads only once...doesnt it ?? Cheers... - Original Message - From: Dino Viehland To: Discussion of IronPython Sent: Friday, August 11, 2006 1:48 PM Subject: Re: [IronPython] Embedded IP eating memory How are you executing the script file? If youre creating a new optimized module each time we wont be able to collection the optimized module code. If on the other hand youre just compiling it as a helper method then when its done running we can collect the code. In pre-RC1 we had a leak where creating a new PythonEngine would result in a leak of a SystemState and ClrModule which were being hung onto by an event rooted in the app domain. So if youre re-creating the engine each time you might be seeing that. Also, now that Ive mentioned events, you might want to check your own C# code if youre using events: Its easy to forget to unhook one and leak memory because the event handler stays alive forever. If none of those turn out to be the problem an option here would be to download the free CLR Profiler and look at the object type that is consuming the increased memory. Itll give you a nice graphical display w/ a block view of whats referencing what. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodolfo CondeSent: Friday, August 11, 2006 12:58 PMTo: Discussion of IronPythonSubject: [IronPython] Embedded IP eating memory Hi I have an IP-Embedded C# application (IP version IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42, Yeah i know, im out of date, but i havent make the change to latest version because i saw there were some API changes :) ), i create one PyEngine, set some global variables and inside a while block i execute this little script every time: import sys try: i = sys.path.index("scripts")except: sys.path.append("scripts") import CMOpFuncionalidad try: pyop = CMOpFuncionalidad.PyOperador(cmop, dba, connID) pyop.atiendeCM() pyop.liberaRecursosBD() pyop = Noneexcept: pyop.liberaRecursosBD() pyop = None raise The module CMOpFuncionaliad is an IPython script i wrote, it contains a class definition. Inside the scripts i use components defined in some assemblies i made (these are already loaded into the CLR). The problem is, after the Engine takes the usual 12M+- of memory it needs, every time the script executes it consumes 2M more, i dont have a clue why is this...Does this version of IP have memory problems ? Or what else could be ?? If you need to see CMOpFuncionalidad.py let me know and ill send it Thanks for your help Greetings... __ Información de NOD32, revisión 1.1703 (20060811) __Este mensaje ha sido analizado con NOD32 antivirus systemhttp://www.nod32.com ___users mailing listusers@lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com__ Información de NOD32, revisión 1.1703 (20060811) __Este mensaje ha sido analizado con NOD32 antivirus systemhttp://www.nod32.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Embedded IP eating memory
I think calling RunFile is going to leak a module each time –we’ll generate a whole new type that isn’t garbage collectible and then we won’t use it again after your RunFile completes. I think you’d be better off doing: object compiledCode = engine.Compile(File.ReadAllText(“scripts/CmOpAtiendeCM.py”)); then repeatedly call: engine.Execute(compiledCode); On the latest versions this changes to: CompiledCode cc = engine.Compile(File.ReadAllText(“scripts/CmOpAtiendeCM.py”)); Then repeatedly call: cc.Execute(); Using the API in this way will result in the code being generated once, but executed multiple times. Currently you’re re-compiling the script each time. So not only should it not leak memory, it should give you better performance as well! The CLR Profiler is available for download here: http://www.microsoft.com/downloads/details.aspx?FamilyID=a362781c-3870-43be-8926-862b40aa0cd0&DisplayLang=en From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodolfo Conde Sent: Friday, August 11, 2006 4:48 PM To: Discussion of IronPython Subject: Re: [IronPython] Embedded IP eating memory Inside the while cycle, i just do this: pyEngine.RunFile("scripts/CMOpAtiendeCM.py"); thats the little script file. The engine is created only once. However, i did inside the cycle a Console.WriteLine("{0} bytes", System.GC.GetTotalMemory(true)) and it gives lower memory usage, there i see that IP seems to be consuming each time the file is run only 2k, no 2m, as the windows taskmanager says I do use events, but i do remove the handlers when no longer in use... Where can i get a free CLR profiler ?? :)... thanks for the help... Greetings - Original Message - From: Dino Viehland To: Discussion of IronPython Sent: Friday, August 11, 2006 1:48 PM Subject: Re: [IronPython] Embedded IP eating memory How are you executing the script file? If you’re creating a new optimized module each time we won’t be able to collection the optimized module code. If on the other hand you’re just compiling it as a helper method then when it’s done running we can collect the code. In pre-RC1 we had a leak where creating a new PythonEngine would result in a leak of a SystemState and ClrModule which were being hung onto by an event rooted in the app domain. So if you’re re-creating the engine each time you might be seeing that. Also, now that I’ve mentioned events, you might want to check your own C# code if you’re using events: It’s easy to forget to unhook one and leak memory because the event handler stays alive forever. If none of those turn out to be the problem an option here would be to download the free CLR Profiler and look at the object type that is consuming the increased memory. It’ll give you a nice graphical display w/ a block view of what’s referencing what. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodolfo Conde Sent: Friday, August 11, 2006 12:58 PM To: Discussion of IronPython Subject: [IronPython] Embedded IP eating memory Hi I have an IP-Embedded C# application (IP version IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42, Yeah i know, im out of date, but i havent make the change to latest version because i saw there were some API changes :) ), i create one PyEngine, set some global variables and inside a while block i execute this little script every time: import sys try: i = sys.path.index("scripts") except: sys.path.append("scripts") import CMOpFuncionalidad try: pyop = CMOpFuncionalidad.PyOperador(cmop, dba, connID) pyop.atiendeCM() pyop.liberaRecursosBD() pyop = None except: pyop.liberaRecursosBD() pyop = None raise The module CMOpFuncionaliad is an IPython script i wrote, it contains a class definition. Inside the scripts i use components defined in some assemblies i made (these are already loaded into the CLR). The problem is, after the Engine takes the usual 12M+- of memory it needs, every time the script executes it consumes 2M more, i dont have a clue why is this...Does this version of IP have memory problems ? Or what else could be ?? If you need to see CMOpFuncionalidad.py let me know and ill send it Thanks for your help Greetings... __ Información de NOD32, revisión 1.1703 (20060811) __ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com __ Información de NOD32, revisión 1.1703 (20060811) __
Re: [IronPython] Embedded IP eating memory
The real problem is that by directly interfacing w/ the Engine APIs you’re not doing a simple import. There is actually an Import API but that’s only going to import the code into the “default module” and not provide you w/ a convenient way to execute it. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodolfo Conde Sent: Friday, August 11, 2006 4:50 PM To: Discussion of IronPython Subject: Re: [IronPython] Embedded IP eating memory PS. The module the script loads with import (CMOpFuncionalidad.py) has 15 global-module variables, but with import the module loads only once...doesnt it ?? Cheers... - Original Message - From: Dino Viehland To: Discussion of IronPython Sent: Friday, August 11, 2006 1:48 PM Subject: Re: [IronPython] Embedded IP eating memory How are you executing the script file? If you’re creating a new optimized module each time we won’t be able to collection the optimized module code. If on the other hand you’re just compiling it as a helper method then when it’s done running we can collect the code. In pre-RC1 we had a leak where creating a new PythonEngine would result in a leak of a SystemState and ClrModule which were being hung onto by an event rooted in the app domain. So if you’re re-creating the engine each time you might be seeing that. Also, now that I’ve mentioned events, you might want to check your own C# code if you’re using events: It’s easy to forget to unhook one and leak memory because the event handler stays alive forever. If none of those turn out to be the problem an option here would be to download the free CLR Profiler and look at the object type that is consuming the increased memory. It’ll give you a nice graphical display w/ a block view of what’s referencing what. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodolfo Conde Sent: Friday, August 11, 2006 12:58 PM To: Discussion of IronPython Subject: [IronPython] Embedded IP eating memory Hi I have an IP-Embedded C# application (IP version IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42, Yeah i know, im out of date, but i havent make the change to latest version because i saw there were some API changes :) ), i create one PyEngine, set some global variables and inside a while block i execute this little script every time: import sys try: i = sys.path.index("scripts") except: sys.path.append("scripts") import CMOpFuncionalidad try: pyop = CMOpFuncionalidad.PyOperador(cmop, dba, connID) pyop.atiendeCM() pyop.liberaRecursosBD() pyop = None except: pyop.liberaRecursosBD() pyop = None raise The module CMOpFuncionaliad is an IPython script i wrote, it contains a class definition. Inside the scripts i use components defined in some assemblies i made (these are already loaded into the CLR). The problem is, after the Engine takes the usual 12M+- of memory it needs, every time the script executes it consumes 2M more, i dont have a clue why is this...Does this version of IP have memory problems ? Or what else could be ?? If you need to see CMOpFuncionalidad.py let me know and ill send it Thanks for your help Greetings... __ Información de NOD32, revisión 1.1703 (20060811) __ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com __ Información de NOD32, revisión 1.1703 (20060811) __ Este mensaje ha sido analizado con NOD32 antivirus system http://www.nod32.com ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] pdb files
I have compiled my application to an exe.Must I distribute the .pdb files along with my app or can I just delete them? ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com