| Summary: | Application crashes | ||
|---|---|---|---|
| Product: | SDL_ttf | Reporter: | Lísias de Castro <saisilcastro> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.14 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 10 | ||
I discovered what was happening. I forgot to destroy the surface and texture before to make a new print. So the computer had memory leak. Now I am debbuging it for more than 5 hours and the application keeps running smoothly. I'm glad you figured it out! And I am glad you do care. |
When I run my application and put some text on the main loop, with the time it crashes. It only occurs when I use the print function. I loaded more than 100 sprites, and leave the application running all the night and it did not crash. But as soon as I use the print function it crashes the application. Here is my code. PLACE_CALL STATUS PLACE_TYPE place_print(struct PlaceTag * to, struct ObjectTag * object, struct FontTag * font, struct ColorTag * color, B8 * format, ...) { if (to && to->machine && to->machine->sdl2 && to->machine->sdl2->pallet && object && font && font->ttf && color) { char * str = NULL; int len = 0; va_list list; va_start(list, format); len = _vscprintf(format, list); str = (char *) calloc(len + 1, sizeof (char)); if (str)vsprintf(str, format, list); va_end(list); SDL_Color fg = {color->r, color->g, color->b, color->a}; object->image->memory = (str) ? image_text_set(str, to->machine->sdl2->pallet, font->ttf, fg) : NULL; if (str)free(str); return (On); } return (Off); } SDL2_PLUGIN_CALL SDL_Texture * SDL2_PLUGIN_TYPE image_text_set(const B8 * text, SDL_Renderer * renderer, TTF_Font * font, SDL_Color text_color) { SDL_Surface * solid = TTF_RenderUTF8_Solid(font, text, text_color); if (solid) { SDL_Texture * to = SDL_CreateTextureFromSurface(renderer, solid); SDL_FreeSurface(solid); return (to); } return (NULL); }