Python multiprocessing fixing memory leakage

11 views
Skip to first unread message
Assigned to txp...@gmail.com by rbo...@gmail.com

Rufino Bolado

unread,
Sep 12, 2018, 6:20:18 AM9/12/18
to Kivy users support
Hello,

I have recently posted about Memory leakage issues with kivy-python. I got very useful advice but I still can't work out how to apply multiprocessing in a Kivy-python based script. Would it be possible to help me to add multiprocessing to the following example code adapted by Глеб Самойлов. As suggested by Geekademy this could solve the issue in which the memory used when a popup window is called never gets released.

Example code:

from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup

import gc


class TestApp(App):
    popup = None

    def build(self):
        ButtonTest = Button(text="Test Info", font_size='24',
                            size_hint=(None, None), size=(250, 100))
        ButtonTest.bind(on_press=self.Info)
        return ButtonTest

    def Info(self, instance):
        if not self.popup:
            box = GridLayout(cols=2, spacing=(0, 0), padding=(10, 10))


            labelTest = Label(text="Test Entry:", font_size='20',
                              size_hint=(None, None), size=(250, 50), halign='left',
                              valign='middle')
            labelTest.text_size = labelTest.size
            box.add_widget(labelTest)

            entryTest = TextInput(multiline=False, font_size='30',
                                  size_hint=(None, None), size=(200, 50),
                                  write_tab=False)
            box.add_widget(entryTest)

            SendButton = Button(text="Send", font_size='20', size_hint=(None, None),
                                size=(250, 50))
            box.add_widget(SendButton)

            CancelButton = Button(text="Cancel", font_size='20',
                              size_hint=(None, None), size=(200, 50))
            box.add_widget(CancelButton)

            self.popup = Popup(title='Test Popup Window', content=box,
                          size_hint=(None, None), size=(600, 400),
                          auto_dismiss=False)

            CancelButton.bind(on_press=self.popup.dismiss)

        self.popup.open()
        gc.collect()


TestApp().run()

Many thanks,
Rufino
Reply all
Reply to author
Forward
0 new messages