Giter Club home page Giter Club logo

Comments (7)

rilysh avatar rilysh commented on August 20, 2024 1

Not only SDL but there are GL calls here and there in the demo program.
If you closely see, the demo program first initializes SDL which allocates some space on the heap. Then moving on there's SDL_CreateWindow(...), SDL_GL_CreateContext(...), and some GL functions which individually allocates several amount of space. and they never get free'd by the program itself. Although the kernel will free the space automatically, there can be a situation where allocated space may swap out.

I'm unsure about Windows internals and the meaning of private bytes. If it means dynamic memory, ProcessHacker perhaps also reports leaked memory that the demo program creates.

I've patched the memory leak issues with SDL, and one other. It does satisfy sanitizer but valgrind still complains about memory leaks. Currently don't have enough time, but a deep look will reveal it. Here's the patch file: https://pastebin.com/SWUMNJ6q

from microui.

darltrash avatar darltrash commented on August 20, 2024

Microui uses about 264~kb, checked it.

from microui.

DiegoJArg avatar DiegoJArg commented on August 20, 2024

Is 'lite' setting up a different kind of GL context with less memory footprint?

from microui.

rilysh avatar rilysh commented on August 20, 2024

No, OpenGL isn't a user level software. The memory usage is from SDL.

If you take a look in example, particularly here, you can see that in the demo SDL is initializing all its subsystem, which individually allocates memory. For example, the demo only needs video and a few basic contexts from SDL but it's initializing other contexts too, (e.g. an audio context).

See: https://github.com/libsdl-org/SDL/blob/efaa58732abb3faf3900b2d93a166b955fbd8ed0/include/SDL.h#L82

Even if you only initialize the video subsystem, I don't think memory footprint will be under some KiB.

from microui.

DiegoJArg avatar DiegoJArg commented on August 20, 2024

Hi again,

So, I have tried today to reduce the SDL subsystems to match with the "lite" that I am comparing with.
I just got a reduction from 30 to 29 Mb of RAM usage.

https://github.com/rxi/lite/blob/38bd9b3326c02e43f244623f97a622b11f074415/src/main.c#L71

  //SDL_Init(SDL_INIT_EVERYTHING);
  SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);

image

Then I thought that probably lite is not using opengl at all, but actually SDL with gdi.
But this test will take some more time, since the microui example is using all GL calls.

  //window = SDL_CreateWindow( NULL,  SDL_WINDOWPOS_UNDEFINED,  SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL);
  window = SDL_CreateWindow( NULL,  SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,  width, height, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN);

Is there any working example on how to use microui with GDI for normal desktop applications ?

from microui.

rilysh avatar rilysh commented on August 20, 2024

I'm not sure about it. Lite seems to only uses SDL for handling every graphics context and SDL under the hood uses OpenGL and GDI (Graphics Device Interface on Windows).

I don't think GDI is the main reason of being "lightweight" on memory. GDI is a legacy component in Windows, mainly used for 2D graphics. But again, I'm not sure how process hacker counts "Private Bytes" in this context.

What's the memory usage in task manager of that application? Is that exactly same as "Private Bytes"?

from microui.

DiegoJArg avatar DiegoJArg commented on August 20, 2024

yes, gdi is legacy, but legacy-support also means high-portability, and that its associated libraries are preloaded by the OS.
However, I have the un-expert theory that opengl interaction with graphics cards requires more buffering of textures, context and scenes, that are not required with GDI. So far, I have seen almost all smallest possible apps with opengl to take 28Mb of Ram as a bare start.
I wonder if one could use microui with the bare canvas drawings of a gdi, direct2d or whatever, or is it just fixed to ogl?

from microui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.