Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 11, 2018 unable to fork: Cannot allocate memory / core.checkedint / gtkd | ||||
---|---|---|---|---|
| ||||
I get dmd ouput: "unable to fork: Cannot allocate memory" when compiling the following code: import std.stdio; import gio.Application : GioApplication = Application; import gtk.Application; import gtk.ApplicationWindow; import gtk.Widget; import gdk.Keysyms; int main(string[] args) { Application application; bool onKeyPress(GdkEventKey* eventKey, Widget widget) { writeln(GdkKeysyms.GDK_Escape); return false; } void activate(GioApplication app) { ApplicationWindow win = new ApplicationWindow(application); win.addOnKeyPress(&onKeyPress); win.showAll(); } application = new Application("org.gtkd.demo.cairo.clock", GApplicationFlags.FLAGS_NONE); application.addOnActivate(&activate); return application.run(args); } with this commandline.. dmd -v -L-lgtkd-3 -run test2.d ..it hangs for a some seconds at.. import core.checkedint (/usr/include/dmd/druntime/import/core/checkedint.d) ..while memory usage grows up to 100%, then continues with other imports.. code test2 function D main function test2.main.onKeyPress function test2.main.activate function std.stdio.writeln!(GdkKeysyms).writeln function std.stdio.File.write!(GdkKeysyms, char).write function std.format.formattedWrite!(LockingTextWriter, char, GdkKeysyms).formattedWrite ... then finally.. cc test2.o -o /tmp/dmd_run6k9PhI -m64 -L/usr/lib/x86_64-linux-gnu -Xlinker --export-dynamic -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl unable to fork: Cannot allocate memory if i comment-out the line.. writeln(GdkKeysyms.GDK_Escape); then it compiles/links/runs fine. I actually want to close the application if escape key is pressed with if (eventKey.keyval == GdkKeysyms.GDK_Escape) ... but i don't know if my imports and the event handler are correct, and i dont know how to close the application yet. I guess there is something wrong during the compilation process? DMD64 D Compiler v2.078.1 gtkd import path is in /etc/dmd.conf: ... [Environment64] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -I/usr/include/dmd/gtkd3 -L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic -fPIC ... |
February 11, 2018 Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd | ||||
---|---|---|---|---|
| ||||
Posted in reply to number | On Sunday, 11 February 2018 at 13:17:13 UTC, number wrote:
> unable to fork: Cannot allocate memory
>
> if i comment-out the line..
> writeln(GdkKeysyms.GDK_Escape);
>
> then it compiles/links/runs fine.
>
> [...]
>
> I actually want to close the application if escape key is pressed with
> if (eventKey.keyval == GdkKeysyms.GDK_Escape) ...
>
Some gtkd demo used core.stdc.stdlib.exit to quit the application.
I use widget.destroy now, seems to work fine.
About the compilation error with writeln(), its not a problem anymore for me right now. Don't know if this is a [known] issue or what the cause is.
|
February 13, 2018 Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd | ||||
---|---|---|---|---|
| ||||
Posted in reply to number | On Sunday, 11 February 2018 at 15:05:26 UTC, number wrote: > On Sunday, 11 February 2018 at 13:17:13 UTC, number wrote: >> unable to fork: Cannot allocate memory >> >> if i comment-out the line.. >> writeln(GdkKeysyms.GDK_Escape); >> >> then it compiles/links/runs fine. >> I just tried again. compiling the following code eats up my 4GB of RAM and fails. Please copy the enumeration from: https://github.com/gtkd-developers/GtkD/blob/master/generated/gtkd/gdk/Keysyms.d into the code. import std.stdio; void main() { writeln(GdkKeysyms.GDK_Escape); } public enum GdkKeysyms { ... } Reducing the number of enum entries step by step finally will make the compilation succeed. Is it normal that it needs so much memory? |
February 13, 2018 Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd | ||||
---|---|---|---|---|
| ||||
Posted in reply to number | On Tuesday, 13 February 2018 at 12:17:31 UTC, number wrote:
> On Sunday, 11 February 2018 at 15:05:26 UTC, number wrote:
>> On Sunday, 11 February 2018 at 13:17:13 UTC, number wrote:
>>> unable to fork: Cannot allocate memory
>>>
>>> if i comment-out the line..
>>> writeln(GdkKeysyms.GDK_Escape);
>>>
>>> then it compiles/links/runs fine.
>>>
>
>
> I just tried again.
> compiling the following code eats up my 4GB of RAM and fails. Please copy the enumeration
> from: https://github.com/gtkd-developers/GtkD/blob/master/generated/gtkd/gdk/Keysyms.d
> into the code.
>
>
> import std.stdio;
>
> void main()
> {
> writeln(GdkKeysyms.GDK_Escape);
> }
>
> public enum GdkKeysyms
> {
> ...
> }
>
>
> Reducing the number of enum entries step by step finally will make the compilation succeed. Is it normal that it needs so much memory?
Yes unfortunately std.conv approaches the problem of printing enums with recursive templates , which eat a ton of memory.
|
February 13, 2018 Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Tuesday, 13 February 2018 at 12:32:58 UTC, Stefan Koch wrote:
> On Tuesday, 13 February 2018 at 12:17:31 UTC, number wrote:
>>
>>
>> I just tried again.
>> compiling the following code eats up my 4GB of RAM and fails. Please copy the enumeration
>> from: https://github.com/gtkd-developers/GtkD/blob/master/generated/gtkd/gdk/Keysyms.d
>> into the code.
>>
>>
>> import std.stdio;
>>
>> void main()
>> {
>> writeln(GdkKeysyms.GDK_Escape);
>> }
>>
>> public enum GdkKeysyms
>> {
>> ...
>> }
>>
>>
>> Reducing the number of enum entries step by step finally will make the compilation succeed. Is it normal that it needs so much memory?
>
> Yes unfortunately std.conv approaches the problem of printing enums with recursive templates , which eat a ton of memory.
Ok, thanks for the info. I guess I'll just use printf then for larger enums.
|
February 13, 2018 Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd | ||||
---|---|---|---|---|
| ||||
Posted in reply to number | On Tuesday, 13 February 2018 at 14:10:44 UTC, number wrote: > Ok, thanks for the info. I guess I'll just use printf then for larger enums. To get the same convince you can use. the enumToString from: https://forum.dlang.org/post/pnggoabnnkojdonyzybx@forum.dlang.org and writeln the result oft that. however it'll cause an error if there are two enum memebrs with the same value. |
February 14, 2018 Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Tuesday, 13 February 2018 at 21:46:31 UTC, Stefan Koch wrote:
> On Tuesday, 13 February 2018 at 14:10:44 UTC, number wrote:
>> Ok, thanks for the info. I guess I'll just use printf then for larger enums.
>
> To get the same convince you can use.
> the enumToString from:
>
> https://forum.dlang.org/post/pnggoabnnkojdonyzybx@forum.dlang.org
>
> and writeln the result oft that.
> however it'll cause an error if there are two enum memebrs with the same value.
Thanks!
|
Copyright © 1999-2021 by the D Language Foundation