-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report how much memory is leaking in vbo memory test
- Loading branch information
Showing
1 changed file
with
17 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,54 @@ | ||
import pygamegltest | ||
import os | ||
|
||
# We have to import at least *one* VBO implementation... | ||
from OpenGL import GL, arrays | ||
from OpenGL.arrays import vbo | ||
|
||
try: | ||
import psutil | ||
except ImportError: | ||
psutil = None | ||
try: | ||
unicode | ||
unicode | ||
except NameError: | ||
unicode = str | ||
unicode = str | ||
long = int | ||
import pytest | ||
import gc | ||
|
||
try: | ||
import numpy as np | ||
except ImportError: | ||
np = None | ||
|
||
|
||
def get_current_memory(): | ||
return psutil.Process(os.getpid()).memory_info().rss | ||
|
||
@pytest.mark.skipif(not psutil,reason='No psutil available') | ||
@pytest.mark.skipif(not np,reason='No Numpy available') | ||
|
||
@pytest.mark.skipif(not psutil, reason="No psutil available") | ||
@pytest.mark.skipif(not np, reason="No Numpy available") | ||
@pygamegltest.pygametest() | ||
def test_sf_2980896(): | ||
"""Test SF#2980896 report of memory leak on VBO transfer""" | ||
data = arrays.GLfloatArray.zeros((1000,)) | ||
memory = get_current_memory() | ||
for i in range(100): | ||
for i in range(100): | ||
new_vbo = vbo.VBO(data) | ||
with new_vbo: | ||
# data is transferred to the VBO | ||
assert new_vbo is not None, new_vbo | ||
new_vbo.delete() | ||
del new_vbo | ||
del new_vbo | ||
gc.collect() | ||
GL.glFinish() | ||
if i < 1: | ||
if i < 1: | ||
# the *first* call can load lots of libraries, etc... | ||
memory = get_current_memory() | ||
else: | ||
assert get_current_memory() - memory < 200, """Shouldn't have any (or at least much) extra RAM allocated...""" | ||
current = get_current_memory() | ||
assert current - memory < 200, ( | ||
"""Shouldn't have any (or at least much) extra RAM allocated, lost: %s""" | ||
% (current - memory) | ||
) # fails only when run in the whole suite... |