SFML community forums

Help => General => Topic started by: Martinezzz on September 19, 2014, 03:53:33 pm

Title: sfml growing memory usage
Post by: Martinezzz on September 19, 2014, 03:53:33 pm
i realize my sfml constantly growing memory usage even for simple rectangle drawing
aprox 1000k /sec
and wery soon get in task menegers top list off all apps runing on my pc

import sfml as sf

# create the main window
window = sf.RenderWindow(sf.VideoMode(640, 480), "pySFML Window")





def square(pos, angle,size):
    sq=sf.graphics.RectangleShape()
   
    sx=size.x
    sy=size.y
    sq.size=sf.Vector2(sx, sy)
    sq.fill_color=sf.Color.RED    

    sq.rotation=angle
    sq.position=pos
    window.draw(sq)
    sq=0
   
# start the game loop
while window.is_open:
    # process events
    for event in window.events:
        # close window: exit
        if type(event) is sf.CloseEvent:
            window.close()

    window.clear() # clear screen
   
    square(sf.Vector2(10, 10),0,sf.Vector2(10, 10))

    window.display() # update the window
Title: Re: sfml growing memory usage
Post by: Laurent on September 19, 2014, 04:17:13 pm
Try the same example in C++ (or a precompiled one from the SDK) and see if it happens too.
Title: Re: sfml growing memory usage
Post by: Martinezzz on September 20, 2014, 08:37:04 am
ha ha i find solution


sq=sf.graphics.RectangleShape()  <--- if this hapens every frame memory grows
def square(pos, angle,size):
    global sq
   
    sx=size.x
    sy=size.y
    sq.size=sf.Vector2(sx, sy)
    sq.fill_color=sf.Color.RED    

    sq.rotation=angle
    sq.position=pos
    window.draw(sq)
Title: Re: sfml growing memory usage
Post by: Martinezzz on September 20, 2014, 10:12:40 am
problem still exsist with


def text(msg,pos,c,s):
   
    create a text
    text = sf.Text(msg)

i print lot of text on screen and this causes memory grow rapidly
Title: Re: sfml growing memory usage
Post by: Laurent on September 20, 2014, 10:19:08 am
Until you try some C++ code, we won't be able to help you. If you can't test C++, then please post on the Python forum and hope that the author of the binding answers ;)