digitalmars.D.learn - How do I trace that memory error?
- Marc (5/7) Feb 26 2018 I've tried both gdb and windbg debugger both it either get a
- Marc (4/21) Feb 26 2018 I'm allocation a class and returning it in a yield. Can it be
- Nicholas Wilson (4/11) Feb 27 2018 "received signal ?" seems like the one of the GC signals used for
- Marc (5/22) Feb 27 2018 An attempt to continue results in crash.
- Stefan Koch (3/10) Feb 27 2018 I'd say allocating in a loop is a bad idea :)
I've tried both gdb and windbg debugger both it either get a "received signal ?" from gdb or crash the GUI application (windbg). The error is:core.exception.OutOfMemoryError src\core\exception.d(696): Memory allocation failedHow do I find out the source of the error?
Feb 26 2018
On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:I've tried both gdb and windbg debugger both it either get a "received signal ?" from gdb or crash the GUI application (windbg). The error is:I'm allocation a class and returning it in a yield. Can it be related? Something like this:core.exception.OutOfMemoryError src\core\exception.d(696): Memory allocation failedHow do I find out the source of the error?Generator!Field fromCSVFile(in string csvFilename) { return new Generator!Field({ string line; while((line = csvFile.readln()) !is null) { Field field = deserializeLine(line); yield(field); writeln("----------------------------------------"); } }); }
Feb 26 2018
On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:I've tried both gdb and windbg debugger both it either get a "received signal ?" from gdb or crash the GUI application (windbg). The error is:"received signal ?" seems like the one of the GC signals used for stopping threads. just get gdb to ignore those.core.exception.OutOfMemoryError src\core\exception.d(696): Memory allocation failedHow do I find out the source of the error?
Feb 27 2018
On Tuesday, 27 February 2018 at 14:06:19 UTC, Nicholas Wilson wrote:On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:An attempt to continue results in crash. I also added in my foreach's body:I've tried both gdb and windbg debugger both it either get a "received signal ?" from gdb or crash the GUI application (windbg). The error is:"received signal ?" seems like the one of the GC signals used for stopping threads. just get gdb to ignore those.core.exception.OutOfMemoryError src\core\exception.d(696): Memory allocation failedHow do I find out the source of the error?scope(exit) { import core.memory : GC; GC.collect(); }But also doesn't solve the issue.
Feb 27 2018
On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:I've tried both gdb and windbg debugger both it either get a "received signal ?" from gdb or crash the GUI application (windbg). The error is:I'd say allocating in a loop is a bad idea :) perhaps you should start with posting the code that leads to this.core.exception.OutOfMemoryError src\core\exception.d(696): Memory allocation failedHow do I find out the source of the error?
Feb 27 2018
On Tuesday, 27 February 2018 at 15:08:23 UTC, Stefan Koch wrote:On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:The code is that one on my second post. The deserializeLine() create allocate instance of Field then return. So yeah, I'm allocating on loop but I don't doing too much. I was watching the memory usage of the application (with win10 taskbar memory usage feature) and I saw it uses only about 4mb on 8gb machine. I've tried build a 64bit executable but I got same error.I've tried both gdb and windbg debugger both it either get a "received signal ?" from gdb or crash the GUI application (windbg). The error is:I'd say allocating in a loop is a bad idea :) perhaps you should start with posting the code that leads to this.core.exception.OutOfMemoryError src\core\exception.d(696): Memory allocation failedHow do I find out the source of the error?
Feb 27 2018
On Tuesday, 27 February 2018 at 15:08:23 UTC, Stefan Koch wrote:On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:I've also tried to create only one instance: create a local variable inside the method then reuse it. I get same error. No debugg tool has helped so far.I've tried both gdb and windbg debugger both it either get a "received signal ?" from gdb or crash the GUI application (windbg). The error is:I'd say allocating in a loop is a bad idea :) perhaps you should start with posting the code that leads to this.core.exception.OutOfMemoryError src\core\exception.d(696): Memory allocation failedHow do I find out the source of the error?
Feb 27 2018
On Tuesday, 27 February 2018 at 16:55:27 UTC, Marc wrote:[...]So deep down the error is in that method which I call from deserializeLine() function:void setValue(T, V)(auto ref T aggregate, string field, V value) { writeln("setting {", field, "} to {", value, "}"); import std.traits : FieldNameTuple; import std.meta : Alias; switch (field) { foreach (fieldName; FieldNameTuple!T) { case fieldName: static if (is(typeof(__traits(getMember, aggregate, fieldName) = value))) { __traits(getMember, aggregate, fieldName) = value; return; } else { assert(false, T.stringof ~ "."~field~" cannot be assigned from a "~V.stringof~"."); } } default: assert(false, T.stringof ~ " has no field named "~field~"."); } }the function is used like this:Field field = new Field(); foreach(CSVLinkedIndex linkedIndex; linkedIndexes) { string value = values[linkedIndex.csv_column_index]; setValue(field, linkedIndex.field_member, value); }which eventually (in about 8 calls) return the error:core.exception.OutOfMemoryError src\core\exception.d(702): Memory allocation failedit uses about 4MB in a 8GB machine then crashs. It's return by the top function using yield:yield(field);But I can't find out why gc fails to allocate at some point. In fact, I've forced the gc to do so in my top loop:foreach(Field field; deserializeFile()) { scope(exit) { import core.memory : GC; GC.collect(); } }Which didn't solve the issue.
Feb 27 2018