Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python/wxPython Reducing memory usage.

Reply
Thread Tools

Python/wxPython Reducing memory usage.

 
 
lotmr
Guest
Posts: n/a
 
      04-09-2005
I have previously posted a simple app I am working on, and while I love
python and wxWindows, after checking the memory usage on such a simple
app (system try application launcher) I see that it climbs to over
17mb! I have reduced all my imports to the bare workable minimum and
that just gets it under 17mb. Is there any way that I could compile or
optimize the my program and/or its memory usage?
(Note: I don't have a problem with making this program win32 specific,
as it already is only win32)


CODE:
#this section broken down soley for readability, normally one line
from wxPython.wx import wxMessageDialog,wxFrame,wxMenu,
wxBitmap,wxOK,wxID_ANY,wxID_EXIT,wxID_ABOUT,
wxBITMAP_TYPE_ICO,wxBITMAP_TYPE_PNG,wxMenuItem,
wxPySimpleApp,wxTaskBarIcon,wxIcon,EVT_TASKBAR_RIG HT_UP,EVT_MENU
#end

from os import startfile
from sys import exit

class MainWindow(wxFrame):
def OnAbout (self, event):
m = wxMessageDialog( self, " LUNCH Bar 0.1 \n"
" A launch bar written in Python using
wxWindows","About LUNCH", wxOK)
m.ShowModal()
m.Destroy
def OnExit (self, event):
self.tbi.Destroy()
exit()
def OnTrayRight (self, event):
self.PopupMenu(self.rhtmenu)
def OnLaunch (self, event):
print event.GetString()
path = 'D:\Program Files\Mozilla Firefox\Firefox.exe'
startfile(path)
def __init__(self,parent,id,title):
wxID_FIREFOX = 1117
wxFrame.__init__(self,parent,wxID_ANY, title, size = (
200,100))
self.tbi = wxTaskBarIcon()
icon = wxIcon('package.ico',wxBITMAP_TYPE_ICO)
self.tbi.SetIcon(icon, '')
self.rhtmenu = wxMenu()
icon = wxBitmap(name = 'ffico.png', type = wxBITMAP_TYPE_PNG)
item = wxMenuItem(parentMenu = self.rhtmenu, id = wxID_FIREFOX,
text='Firefox')
item.SetBitmap(icon)
self.rhtmenu.Append(wxID_EXIT, "&Exit"," Terminate this program")
self.rhtmenu.Append(wxID_ABOUT, "&About"," Information about this
program")
self.rhtmenu.AppendSeparator()
self.rhtmenu.AppendItem(item)
EVT_TASKBAR_RIGHT_UP(self.tbi, self.OnTrayRight)
EVT_MENU(self, wxID_ABOUT, self.OnAbout)
EVT_MENU(self, wxID_EXIT, self.OnExit)
EVT_MENU(self, wxID_FIREFOX, self.OnLaunch)


appwin = wxPySimpleApp()
frame = MainWindow(None, -1, "Small editor")
appwin.MainLoop()

 
Reply With Quote
 
 
 
 
Joe
Guest
Posts: n/a
 
      04-09-2005
On 8 Apr 2005 23:35:57 -0700, "lotmr" <(E-Mail Removed)> wrote:
>Is there any way that I could compile or optimize the my program and/or its memory usage?


.... and ideally, if we could also reduce the size of the DLL, so that
it would only include the widgets actually used, it'd be even nicer.

>(Note: I don't have a problem with making this program win32 specific,
>as it already is only win32)


I don't have much experience with it, but is the PythonWin wrapper to
MFC horrible to use as compared to wxWidgets? If it's good enough and
you don't care about non-Windows platforms, you'll probably save a lot
of RAM and file footprint.

Joe.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reducing memory overhead for dictionaries by removing precomputed hash kirat.singh@gmail.com Python 0 04-18-2006 02:45 AM
Reducing master password check? Gusvaldo Firefox 1 04-18-2005 10:31 PM
Reducing cost for Cisco memory upgrade Johnson Ng Cisco 4 05-26-2004 03:49 AM
Reducing Spam Associated with Posting to Newsgroups Microsoft Communities Team [MSFT] ASP .Net 0 10-14-2003 10:26 PM
Reducing memory size of pictures in Canon A70 Richard Hinton Digital Photography 2 09-20-2003 12:24 PM



Advertisments