Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd

2018-02-14 Thread number via Digitalmars-d-learn

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/pnggoabnnkojdonyz...@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!


Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd

2018-02-13 Thread Stefan Koch via Digitalmars-d-learn

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/pnggoabnnkojdonyz...@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.


Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd

2018-02-13 Thread number via Digitalmars-d-learn

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.


Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd

2018-02-13 Thread Stefan Koch via Digitalmars-d-learn

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.


Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd

2018-02-13 Thread number via Digitalmars-d-learn

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?


Re: unable to fork: Cannot allocate memory / core.checkedint / gtkd

2018-02-11 Thread number via Digitalmars-d-learn

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.






unable to fork: Cannot allocate memory / core.checkedint / gtkd

2018-02-11 Thread number via Digitalmars-d-learn

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();
win.showAll();
}

	application = new Application("org.gtkd.demo.cairo.clock", 
GApplicationFlags.FLAGS_NONE);

application.addOnActivate();
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

...