[Xcb] [RFC] XCB without use of malloc()
Maxim Levitsky
maximlevitsky at gmail.com
Sun Jan 6 02:22:01 PST 2008
Hi,
I am currently thinking of writing my own X toolkit, mostly just for fun, and
to learn X deeply, plus I want to prove that it is possible to create
1) easy to use
2) fast
3) theme-able and beautiful toolkit
I need to choose what library to use Xlib or XCB.
I like XCB, since it is small, simple, and has nice coding style.
And besides XCB is newer, and it probably going to obsolete Xlib in few years.
But I have one problem with XCB, I think that it uses malloc() too often.
It isn't question of speed, I know malloc() is quite fast, and used today by
all languages very often.
But calling malloc over and over again fragments memory, thus I want to avoid
using it heavily.
For example in the event loop I want to allocate fixed buffer for incoming
events, and use it over and over instead of mallocing and freeing it.
So how about that, how about adding an option for reply-receiving functions to
get a pointer to already allocated data, (at least to a subset of functions).
(My goal is to create a very memory efficient tookit, to fit whole large GUI
in few MBs, so I don't want to waste heap on fragmentation).
On the other hand XLib doesn't have this feature, but I have seen that it has
problems with threads, so I don't like to use it.
Speaking of threads, how do you deal with them?
I am thinking that each thread should open a separate connection to X server,
and thus it will get its own events in its own private message loop.
Is this a good/working design?
(And I am thinking that at least theoretically it is possible to do in XLib
too, with help of XInitThreads)
I am waiting for your comments,
Best regards,
Maxim Levitsky
More information about the Xcb
mailing list