Re: Get largest heap object at runtime? ...tracking the leak
On Monday, 22 January 2018 at 06:15:24 UTC, Dmitry Olshansky wrote: On Sunday, 21 January 2018 at 17:28:13 UTC, Andres Clari wrote: Hi, is there any way to get from the GC all allocated objects, so I can see their size and find where I'm leaking memory? Or perhaps a good tool to help with this issue... I tried building my program with "profile-gc" but I got an invalid MemoryOperationError with no stack trace... so no luck using that. And the leak is only obvious when running in production, where after 6 hours I've seen 1.5Gb of memory usage. Are you by chance using vibe.d? In versions 0.8.x I observe a huge memory leak. Might be your problem. Right now, I'm able to extend the life of my program by injecting calls to: GC.collect GCminimize Within an event that happens every 5 seconds, which I estimate will give me about a week before the program's memory is again at +1.5Gb. Yeah. Although after doing some manual tracking and isolation of the suspect routines, I found that using "std.concurrency.spawn" to run a http post request with the "requests" library was the leaking suspect. I'm triggering some 15 requests every 5 seconds in production, so it's obvious there, but querying "GC.usedSize" I was able to observe the same on my dev environment. After removing the "spawn" call, and wrapping up the post code inside a "runTask", it seems to work properly now, and so far I have a consistently small memory size in production. Not sure why "spawn" would leak like that tho. I would assume that once the thread exits, it would get destroyed and it's resources reclaimed, specially when I have calls to "GC.collect and GC.minimize".
Re: Get largest heap object at runtime? ...tracking the leak
On Sunday, 21 January 2018 at 17:28:13 UTC, Andres Clari wrote: Hi, is there any way to get from the GC all allocated objects, so I can see their size and find where I'm leaking memory? Or perhaps a good tool to help with this issue... I tried building my program with "profile-gc" but I got an invalid MemoryOperationError with no stack trace... so no luck using that. And the leak is only obvious when running in production, where after 6 hours I've seen 1.5Gb of memory usage. Are you by chance using vibe.d? In versions 0.8.x I observe a huge memory leak. Might be your problem. Right now, I'm able to extend the life of my program by injecting calls to: GC.collect GCminimize Within an event that happens every 5 seconds, which I estimate will give me about a week before the program's memory is again at +1.5Gb.
Re: Templated Binary Search Tree treats class as const, compiler complains
On Sunday, 21 January 2018 at 20:46:56 UTC, Timon Gehr wrote: On 21.01.2018 21:20, Mark wrote: Just realized that I commented out the creation of the BST new link: https://dpaste.dzfl.pl/ce620cbee919 'in' means 'const scope', but it seems you need references that are allowed to mutate the incoming items. Remove the 'in' attribute from the parameters and your problem should disappear. Ok, I was looking at the wrong stuff. Looking at varidiac functions in the book, I'm seeing what you're saying. I thought that was used as a keyword for variadic arguments. Thanks, that worked perfectly! Mark.
Re: Templated Binary Search Tree treats class as const, compiler complains
On 21.01.2018 21:20, Mark wrote: Just realized that I commented out the creation of the BST new link: https://dpaste.dzfl.pl/ce620cbee919 'in' means 'const scope', but it seems you need references that are allowed to mutate the incoming items. Remove the 'in' attribute from the parameters and your problem should disappear.
Re: Templated Binary Search Tree treats class as const, compiler complains
Just realized that I commented out the creation of the BST new link: https://dpaste.dzfl.pl/ce620cbee919
Templated Binary Search Tree treats class as const, compiler complains
Hello, I re wrote my old BST. This one is far more complete and clean. However, It fails my final unittest when I try to stick a class in as its type. Link: https://dpaste.dzfl.pl/95e1ae49b25b Ive done this type of thing before, but it is giving me this error: BinarySearchTree.d(30): Error: function BinarySearchTree.BinarySearchTree!(Empty).BinarySearchTree.New (Empty item) is not callable using argument types (const(Empty)) BinarySearchTree.d(40): Error: function BinarySearchTree.BinarySearchTree!(Empty).BinarySearchTree.New (Empty item) is not callable using argument types (const(Empty)) BinarySearchTree.d(574): Error: template instance BinarySearchTree.BinarySearchTree!(Empty) error instantiating the New method is on line 94; I was looking through the Programming in D book, and can't find what this is really telling me. I have templated Stack and queue classes that don't give me these errors?? How do I make the BST accept classes like the one in my test? I don't deal with const stuff, so I'm not too sure what to look for concerning these problems. I'm still looking in the book/site for answers. Thanks!
Re: How do I solve this kind of conflict?
On Sunday, 21 January 2018 at 16:22:33 UTC, Marc wrote: But libraries has this defined: extern(C) int callback(void*, int, char** , char**){ Just rename one of the functions. It is really bad form to have extern(C) functions have a common word like this exactly because they share a namespace and make conflicts likely. I'd name one like `callback_lib_name` and the other `callback_other_lib`. You might even be able to do `alias callback = callback_lib_name;` after the definition to keep all the D code compiling with no other changes.
Re: Cannot initialize associative array
On 2018-01-20 00:16, rumbu wrote: According to this (https://dlang.org/spec/hash-map.html#static_initialization) this is correct static initialization for AA: immutable RoundingMode[string] ibmRounding = [ ">" : RoundingMode.towardPositive, "<" : RoundingMode.towardNegative, "0" : RoundingMode.towardZero, "=0": RoundingMode.tiesToEven, "=^": RoundingMode.tiesToAway ]; Error: non-constant expression `[">":cast(RoundingMode)2, "<":cast(RoundingMode)3, "0":cast(RoundingMode)4, "=0":cast(RoundingMode)0, "=^":cast(RoundingMode)1]` RoundingMode is an enum. An alternative to the shared module constructor is to declare it as an enum instead of immutable. But that will allocate a new associative array every time the enum is referenced. enum a = [1: 2, 3: 4]; -- /Jacob Carlborg
Get largest heap object at runtime? ...tracking the leak
Hi, is there any way to get from the GC all allocated objects, so I can see their size and find where I'm leaking memory? Or perhaps a good tool to help with this issue... I tried building my program with "profile-gc" but I got an invalid MemoryOperationError with no stack trace... so no luck using that. And the leak is only obvious when running in production, where after 6 hours I've seen 1.5Gb of memory usage. Right now, I'm able to extend the life of my program by injecting calls to: GC.collect GCminimize Within an event that happens every 5 seconds, which I estimate will give me about a week before the program's memory is again at +1.5Gb.
How do I solve this kind of conflict?
I was using a Sqlite3 library then I included another library that started the conflict. From what I could tell, it seems it's another Sqlite3 engine that the included library uses. The link error is: .dub\build\application-debug-windows-x86-dmd_2076-E7D07B7BDA58325E30A3C637FC043AFE\foo.obj(ytdl) Offset BA31FH Record Type 00C3 Error 1: Previous Definition Different : _callback Error: linker exited with status 1 My guess is it's symbols visibility issue? and how can I solve this? But libraries has this defined: extern(C) int callback(void*, int, char** , char**){ I've trid mark the one without private as such but it didn't change anything. NOTE: Albeit I'm using dub, both those libraries were included directly (except the dependences of one of them).
Re: -transition=safe and DIP1000
My understanding is, currently read DIP1000 as: "NB: this DIP is out of sync with -dip1000 compiler switch implementation ...". My own current problem fits well in this thread: I want to push forward support of -dip1000 in phobos, testing each module's compatibility with -dip1000 individually and try to fix where required/possible. There is https://github.com/dlang/phobos/blob/master/posix.mak, I added to my forks file: DFLAGSSINGLE=$(DFLAGS) -dip1000 and fiddled to introduce DFLAGSSINGLE in the proper target, yet realizing, make/makefile and it's cryptic details knowledge largely left my brain. Can anybody give me a hint, ideally introducing a target for that purpose, if required? Invocation will be: make -f posix.mak std/somemodule.test ?
Re: -transition=safe and DIP1000
On Sunday, 21 January 2018 at 10:27:05 UTC, Mike Franklin wrote: On Sunday, 21 January 2018 at 10:04:36 UTC, Mike Franklin wrote: What is/was `transition=safe`? I can't find any documentation on it. Adding -transition=? to the dmd (v2.078.0) command line doesn't show safe listed. My understanding is, currently read DIP1000 as: "NB: this DIP is out of sync with -dip1000 compiler switch implementation ...". Yes, the representation of DIP1000.md deserves improvement: It takes (too) much time to get a grip on it, maybe discouraging, though the idea itself is not that complicated as it is presented. I additionally warmly recommend Walter Bright's "Pointers Gone Wild: Memory Safety and D - Walter Bright | DConf2017" https://www.youtube.com/watch?v=iDFhvCkCLb4
Re: -transition=safe and DIP1000
On Sunday, 21 January 2018 at 10:04:36 UTC, Mike Franklin wrote: What is/was `transition=safe`? I can't find any documentation on it. Well, I found http://forum.dlang.org/post/gquxgusfhyigirfpe...@forum.dlang.org But, didn't really clear much up for me.
Re: -transition=safe and DIP1000
Mike Franklin wrote: And what does "NB" mean? "nota bene". used as "pay attention to the following".
-transition=safe and DIP1000
I found the following statement in the DIP1000 document (https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md) NB: this DIP is out of sync with -transition=safe implementation available in dmd and pending a rewrite. Most key points still apply though. What is/was `transition=safe`? I can't find any documentation on it. And what does "NB" mean? Thanks, Mike