Comment 14 for bug 981224

Revision history for this message
David Klasinc (bigwhale) wrote :

So, I took some time to do a little testing and write some experimental code. And I did some reading to make sure that I understand the PS output correctly.

First run python and see how much memory it is using:
bigwhale@thefish:~/Code/Kazam/unstable/bin$ python

(open another terminal ...)

bigwhale@thefish:~$ ps aux | grep python | head -1
bigwhale 2264 0.0 0.0 -> 38896 <- -> 5916 <- pts/3 S+ 11:29 0:00 python

The numbers reported are VSZ and RSS. Virtual memory size and resident (not swapped) memory size. Which would mean that python alone is using around 38MB of RAM. In reality this is what python would use if it would be the only running program on the computer. 38MB also includes memory that is shared between other programs.

Next, you can try to load only the certain libraries that Kazam requires to work:

bigwhale@thefish:~/Code/Kazam/unstable/bin$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from gi.repository import Gtk, Gdk, GObject, GdkPixbuf
import gst, pygst, cairo, logging, os, multiprocessing, sys
from gettext import gettext as _
from subprocess import Popen
from kazam.pulseaudio.pulseaudio import pulseaudio_q

bigwhale@thefish:~$ ps aux | grep python | head -1
bigwhale 1804 0.0 0.3 -> 417624 <- -> 32084 <- pts/3 Sl+ 10:47 0:00 python

This means that only the imports are more than 400MB of memory. This is before GUI is even initialized. Non shared memory usage that only this python instance is using is ~32MB

Then you can actually import the GUI by pasting the lines below in the python interpreter:

class KazamApp(GObject.GObject):
  def __init__(self):
    GObject.GObject.__init__(self)
    self.builder = Gtk.Builder()
    self.builder.add_from_file("../data/ui/kazam.ui")
    self.builder.connect_signals(self)
    for w in self.builder.get_objects():
      if issubclass(type(w), Gtk.Buildable):
        name = Gtk.Buildable.get_name(w)
        setattr(self, name, w)
  def cb_record_clicked(self):
    pass
  def cb_region_toggled(self):
    pass
  def cb_cursor_switch(self):
    pass
  def cb_timer_switch(self):
    pass
  def cb_codec_changed(self):
    pass
  def cb_volume_changed(self):
    pass
  def cb_volume2_changed(self):
    pass
  def cb_audio_changed(self):
    pass
  def cb_audio2_changed(self):
    pass
  def cb_video_changed(self):
    pass
  def cb_delete_event(self):
    pass

foo = KazamApp()
foo.window.show_all()
Gtk.main()

Checking memory usage again will result in this:
bigwhale@thefish:~$ ps aux | grep python | head -1
bigwhale 2111 0.5 0.4 -> 749844 <- -> 33368 <- pts/3 Sl+ 11:15 0:00 python

It jumped to almost 750MB. And this is before anything actually happens in Kazam and before anything at all was initialized, variables set and so on.

This huge memory usage is mostly shared memory that is already being used if you are using Gnome.