digitalmars.D.learn - unable to fork: Cannot allocate memory / core.checkedint / gtkd
- number (69/69) Feb 11 2018 I get dmd ouput:
- number (6/14) Feb 11 2018 Some gtkd demo used core.stdc.stdlib.exit to quit the application.
- number (19/27) Feb 13 2018 I just tried again.
- Stefan Koch (3/30) Feb 13 2018 Yes unfortunately std.conv approaches the problem of printing
- number (3/32) Feb 13 2018 Ok, thanks for the info. I guess I'll just use printf then for
- Stefan Koch (7/9) Feb 13 2018 To get the same convince you can use.
- number (2/11) Feb 14 2018 Thanks!
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 ...
Feb 11 2018
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.
Feb 11 2018
On Sunday, 11 February 2018 at 15:05:26 UTC, number wrote:On Sunday, 11 February 2018 at 13:17:13 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?unable to fork: Cannot allocate memory if i comment-out the line.. writeln(GdkKeysyms.GDK_Escape); then it compiles/links/runs fine.
Feb 13 2018
On Tuesday, 13 February 2018 at 12:17:31 UTC, number wrote:On Sunday, 11 February 2018 at 15:05:26 UTC, number wrote:Yes unfortunately std.conv approaches the problem of printing enums with recursive templates , which eat a ton of memory.On Sunday, 11 February 2018 at 13:17:13 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?unable to fork: Cannot allocate memory if i comment-out the line.. writeln(GdkKeysyms.GDK_Escape); then it compiles/links/runs fine.
Feb 13 2018
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:Ok, thanks for the info. I guess I'll just use printf then for larger enums.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.
Feb 13 2018
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.
Feb 13 2018
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:Thanks!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.
Feb 14 2018