wxPython/python memory problems

I have to say that i really like wxpython, but i recently droped using it because of memory consumption. Of course it is more a python problem but wxpython is using python so it has the same problems. Python is using way to much memory for simple applications. It is surpring for me that a very good programmming language has a very bad memory management. I recently discovered that until version 2.5 python doesn’t release memory on a long term, so basically after a long period of time an application built with python crash with out of memory exception (not in all situations). In my opinion this is a huge flaw, i’m not an expert but i simply cannot understand the decision to ignore the problem until version 2.5. Even in version 2.5 python use at least 20 mb of memory for any simple applications, so almost nothin changed. For example i created a frame with a widget in wxpython and then use py2exe. This very simple application use at least 20 mb of memory. In this conditions i cannot use wxpython for applications that require low memory consumption. How can i create , for example, a performance tweaking application when my application alone use 20-30 mb of memory ?
I wait for your opinions about this subject.

michael michael wrote:

How can i create , for example, a performance tweaking application when my application alone use 20-30 mb of memory ?
I wait for your opinions about this subject.

GUIs require a lot of memory, even though there are others that require less than wxPython.

Write a CLI application. In C or assembler to make sure you are consuming exactly what you need and nothing more.

···

--
Rastertech España S.A.
  Grzegorz Adam Hankiewicz
/Jefe de Producto TeraVial/

C/ Perfumería 21. Nave I. Polígono industrial La Mina
28770 Colmenar Viejo. Madrid (España)
Tel. +34 918 467 390 (Ext.17) *·* Fax +34 918 457 889
ghankiewicz@rastertech.es *·* www.rastertech.es <http://www.rastertech.es/&gt;

http://www.codeproject.com/system/howbig.asp

-Matthias

···

Am 13.06.2007, 09:36 Uhr, schrieb michael michael <pythonmg@gmail.com>:

I wait for your opinions about this subject.

[Post reformattedwith paragraphs]

I have to say that i really like wxpython, but i recently droped using it
because of memory consumption.

Of course it is more a python problem but
wxpython is using python so it has the same problems.
Python is using way to
much memory for simple applications. It is surpring for me that a very good
programmming language has a very bad memory management. I recently
discovered that until version 2.5 python doesn't release memory on a long
term, so basically after a long period of time an application built with
python crash with out of memory exception (not in all situations).

This simply isn't true - you misunderstand the problem, the solution,
and symptoms.

In my
opinion this is a huge flaw, i'm not an expert but i simply cannot
understand the decision to ignore the problem until version 2.5.

Because it's not actually a problem, except for certain corner cases.
The change was made to help support those corner cases, not because
Python applications come with built in memory leaks.

Even in
version 2.5 python use at least 20 mb of memory for any simple applications,
so almost nothin changed.

Note that the changes made have nothing to do with the memory
footprint of an application. And, of course, as the link provided by
Matthias says, this number is misleading where it's not totally
worthless.

For example i created a frame with a widget in
wxpython and then use py2exe. This very simple application use at least 20
mb of memory. In this conditions i cannot use wxpython for applications that
require low memory consumption.

Define "low memory consumption".

How can i create , for example, a
performance tweaking application when my application alone use 20-30 mb of
memory ?

The environment your application runs in is what determines the
acceptable amount of memory you can use, not the applications purpose.
Of course, the sort of people who use "memory tweaking applications"
tend obsess over numbers, often with little or no real knowledge of
what those numbers mean.

I wait for your opinions about this subject.

All that said, yes, wxPython is memory heavy - there are a lot of C++
objects created in memory, and a lot of Python objects wrapping them.
The libraries are large and since wx applications aren't that common
you often don't realize the benefits of sharing the code space. This
is a natural consequence of using feature rich tools and is to be
expected.

···

On 6/13/07, michael michael <pythonmg@gmail.com> wrote:

michael michael wrote:

I have to say that i really like wxpython, but i recently droped using it because of memory consumption. Of course it is more a python problem but wxpython is using python so it has the same problems. Python is using way to much memory for simple applications. It is surpring for me that a very good programmming language has a very bad memory management. I recently discovered that until version 2.5 python doesn't release memory on a long term, so basically after a long period of time an application built with python crash with out of memory exception (not in all situations).

Chris has mentioned that this is not true, but didn't give any details. I thought I would give some details to help you understand what the real behavior was.

If I understand correctly the way it works is Python asks the OS for large blocks of memory as it needs more of them, and it then manages its own allocations within these blocks as needed. It allocates and frees smaller chunks of the large blocks as PyObjects are created and destroyed. If it runs out of space then it asks the OS for another large block. This allows Python to be more efficient about memory management than the standard C library would be, and also allows the garbage collector to be more intimate with the memory allocation structures. The problem is that there was an assumption that the memory requirements of a Python app would remain roughly the same over the life of the app, so it would never give those large blocks back to the OS. The corner case Chris mentioned is apps that need a huge amount of space to start with, (loading a large DOM tree for example) and then for the rest of their life they need only a small amount. That's an obvious waste for that particular (but rare) case, and that is what was changed in 2.5. Python will now give the large blocks back to the OS if there are no active Python objects living on them.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!