Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many open files error #55

Open
DhruvaSambrani opened this issue Feb 10, 2022 · 5 comments
Open

Too many open files error #55

DhruvaSambrani opened this issue Feb 10, 2022 · 5 comments

Comments

@DhruvaSambrani
Copy link

Base.IOError("readdir(\"./images\"): too many open files (EMFILE)", -24)

I made my own version of the flappy bird game, and I face this issue if I play it for a while. It looks like GameZero is not GC-ing some images(?)

Note, I change the bird image everytime I press space, and for a game like flappy bird, that is quite often. I thought the image will be reused?

@DhruvaSambrani
Copy link
Author

Also, ALSA lib conf.c:4563:(snd_config_update_r) cannot access file /usr/share/alsa/alsa.conf pops up just before this error is thrown. Note that I have applied the fix as suggested in #42, and audio works well until this error.

@levje
Copy link

levje commented Feb 20, 2023

Hi. I'm having the same problem with fonts. It seems like the following function loads a new instance of the same font file every time we create a new TextActor. The second line of the function creates a new TextActor and it never closes the TextActor.

function TextActor(text::String, font_name::String; font_size=24, color=Int[255,255,0,255], kv...)
    font = TTF_OpenFont(file_path(font_name, :fonts), font_size)
    sf = TTF_RenderText_Blended(font, text, SDL_Color(color...))
    w, h = size(sf)
    a = Actor(
        text, 
        sf, 
        Rect(0, 0, Int(w), Int(h)), 
        [1.,1.], 
        0,
        255,
        Dict{Symbol,Any}()
    )

    for (k, v) in kv
        setproperty!(a, k, v)
    end
    return a
end```

@aviks
Copy link
Owner

aviks commented Feb 20, 2023

@MrZarfir good find. Can you try adding a TTF_CloseFont(font) call after the sf = TTF_Render_Text(...) call and test if your problem goes away?

@levje
Copy link

levje commented Feb 21, 2023

@MrZarfir good find. Can you try adding a TTF_CloseFont(font) call after the sf = TTF_Render_Text(...) call and test if your problem goes away?

Indeed, my problem goes away after adding a closing call. I don't have access to push the new change to a new branch, but it would be appreciated if you can add this small change (unless you can give me access so I can push it).

Thank you for your quick response.

@aviks
Copy link
Owner

aviks commented Feb 27, 2023

don't have access to push the new change to a new branch

@MrZarfir You don't need push access to collaborate on an open source repository. You typically create a fork, and make a pull request from there. See this github documentation

Hower, in this case, I have created this pull request here: #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants