Repository: kivy/kivy

Issue:
Texture ID leak
I've discovered an issue in which texture id's appear to be leaking during a texture update for a Label.  While on Windows you can see the id's jumping around, although it doesn't seem to be too much of a problem.  However, on my Android 2.2 tablet, the id's grow until they hit 2.1 billion (the maximum size of a signed 32 bit integer) and which point I start to see this message in my logs:
I/python ( 1309): Exception OverflowError: 'Python int too large to convert to C long' in 'kivy.graphics.context.Context.dealloc_texture' ignored

After this runs for a while, my application runs out of memory and then crashes.

I've created a simple hello world and output log of the issue here:
https://gist.github.com/flionetti/6d394ae80ba28c77fa7d

If you uncomment the line "lbl.text_size = (120, 60)", then the problem mysteriously goes away.

This same issue is also reference by Joran in this post:
https://groups.google.com/forum/#!topic/kivy-users/fBpzeNluqpE

Edit: In case it's helpful, I've added an excerpt of the logfile on an Android 2.2 system where the kivy bug crashes the app after running for a while.
## <bountysource-plugin>

Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/2372235-texture-id-leak?utm_campaign=plugin&utm_content=tracker%2F42681&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F42681&utm_medium=issues&utm_source=github).
</bountysource-plugin>

Texture ID leak
I've discovered an issue in which texture id's appear to be leaking during a texture update for a Label.  While on Windows you can see the id's jumping around, although it doesn't seem to be too much of a problem.  However, on my Android 2.2 tablet, the id's grow until they hit 2.1 billion (the maximum size of a signed 32 bit integer) and which point I start to see this message in my logs:
I/python ( 1309): Exception OverflowError: 'Python int too large to convert to C long' in 'kivy.graphics.context.Context.dealloc_texture' ignored

After this runs for a while, my application runs out of memory and then crashes.

I've created a simple hello world and output log of the issue here:
https://gist.github.com/flionetti/6d394ae80ba28c77fa7d

If you uncomment the line "lbl.text_size = (120, 60)", then the problem mysteriously goes away.

This same issue is also reference by Joran in this post:
https://groups.google.com/forum/#!topic/kivy-users/fBpzeNluqpE

Edit: In case it's helpful, I've added an excerpt of the logfile on an Android 2.2 system where the kivy bug crashes the app after running for a while.
## <bountysource-plugin>

Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/2372235-texture-id-leak?utm_campaign=plugin&utm_content=tracker%2F42681&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F42681&utm_medium=issues&utm_source=github).
</bountysource-plugin>



Discussion:

Resolving patch:
diff --git a/kivy/core/text/__init__.py b/kivy/core/text/__init__.py
--- a/kivy/core/text/__init__.py
+++ b/kivy/core/text/__init__.py
@@ -540,7 +540,7 @@ def render(self, real=False):
             h = uh
         if h > 1 and w < 2:
             w = 2
-        return w, h
+        return int(w), int(h)
 
     def _texture_refresh(self, *l):
         self.refresh()
diff --git a/kivy/core/text/markup.py b/kivy/core/text/markup.py
--- a/kivy/core/text/markup.py
+++ b/kivy/core/text/markup.py
@@ -366,7 +366,7 @@ def _pre_render(self):
             w = 1
         if h < 1:
             h = 1
-        return w, h
+        return int(w), int(h)
 
     def _real_render(self):
         lines = self._cached_lines


Test patch: