GC and sensible data read by File

2020-10-04 Thread frame via Digitalmars-d-learn
Hello, I'm new to D and try to find out a memory leak in my program. I inspected the private bytes with VmMap on Windows to see which data is still kept. Besides the actual memory leak I was surprised to find out there are contents of my previoulsy read configuration INI file. So my

Edit

2020-10-05 Thread frame via Digitalmars-d-learn
So I found out that there is nothing wrong with the method as in a test environment the allocated memory block is removed after GC.minimize(). Still need to find out why other blocks are not released. However, is there a way to debug currently allocated variables by the GC?

Re: Edit

2020-10-24 Thread frame via Digitalmars-d-learn
On Monday, 5 October 2020 at 11:28:56 UTC, ryuukk_ wrote: On Monday, 5 October 2020 at 11:14:47 UTC, frame wrote: So I found out that there is nothing wrong with the method as in a test environment the allocated memory block is removed after GC.minimize(). Still need to find out why other

Template pattern delegate?

2020-10-25 Thread frame via Digitalmars-d-learn
Is there a possibility to write templated code / custom trait pattern with usage like a delegate? I have a try-catch block with different types and don't want to repeat myself in every method again. It's always the same, just what's tried changes, eg.: pseudo code: template myStuff(mixin

Re: Template pattern delegate?

2020-10-25 Thread frame via Digitalmars-d-learn
On Sunday, 25 October 2020 at 12:02:10 UTC, Ali Çehreli wrote: On 10/25/20 4:30 AM, frame wrote: Is there a possibility to write templated code / custom trait pattern with usage like a delegate? I have a try-catch block with different types and don't want to repeat myself in every method

Re: this T / variadic template and interfaces

2020-10-27 Thread frame via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 10:41:06 UTC, Jacob Carlborg wrote: On Tuesday, 27 October 2020 at 09:40:33 UTC, frame wrote: Hmm, a question of design. Is there also a convenient way to pass the arguments to a template or get a Variant[] from it? Convenient, no not that I know of. You can

Re: this T / variadic template and interfaces

2020-10-27 Thread frame via Digitalmars-d-learn
On Monday, 26 October 2020 at 13:02:33 UTC, Jacob Carlborg wrote: On Monday, 26 October 2020 at 11:14:47 UTC, frame wrote: Is there any way to get this working? I know, I could use a known object to feed the arguments and use that instead - but I want to keep things simple as possible. As

this T / variadic template and interfaces

2020-10-26 Thread frame via Digitalmars-d-learn
Did not find this topic: I have an interface and some wrapper classes that use it. The wrapper's methods should accept variadic arguments. The runtime should only work with the interface, trying casting to a wrapper is not an option, because it's a plugin design. - defining a variadic

Re: this T / variadic template and interfaces

2020-10-27 Thread frame via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 11:30:53 UTC, frame wrote: On Tuesday, 27 October 2020 at 10:41:06 UTC, Jacob Carlborg wrote: if (_arguments[i] == typeid(ubyte[])) { auto foo = va_arg!(ubyte[])(_argptr); } The same is working with variadic template. I am missing something? Never mind, I

Re: this T / variadic template and interfaces

2020-10-26 Thread frame via Digitalmars-d-learn
On Monday, 26 October 2020 at 11:48:48 UTC, Simen Kjærås wrote: This makes sense if you consider that the user of the interface has no knowledge of the types that implement it, and vice versa: the implementing class has no idea which instantiations to make, and the user has no idea which

Re: Template pattern delegate?

2020-10-26 Thread frame via Digitalmars-d-learn
On Monday, 26 October 2020 at 09:25:03 UTC, Jacob Carlborg wrote: On Monday, 26 October 2020 at 00:56:26 UTC, frame wrote: If you pass the delegate as a template parameter/alias parameter, it's more likely to be inlined: auto myStuff(alias fn)() { try return fn(); catch (Exception

Re: How to build dll?

2020-12-03 Thread frame via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 19:42:37 UTC, Jack wrote: What am I missing? As always... have you tired dmd -m32mscoff ?

Are JSONOptions broken?

2020-11-28 Thread frame via Digitalmars-d-learn
I need to encode a key as string through json. This throws an UTF-exception: auto json = JSONValue(cast(char[])[0x00, 0x7D, 0xFE, 0xFF, 0x14, 0x32, 0x43, 0x10]); writeln(json.toString(JSONOptions.escapeNonAsciiChars)); Makes no sense. Either the bytes should be properly escaped or there

Re: Are JSONOptions broken?

2020-11-28 Thread frame via Digitalmars-d-learn
On Saturday, 28 November 2020 at 16:59:11 UTC, ag0aep6g wrote: Makes perfect sense. The option is called "escapeNonAsciiChars", not "escapeNonUnicodeChars". This is a slash: / This is a backslash: \ There are no slashes in your string. Thanks, I realized that the options are only for

Anyone has links to useful short-snippets of trait pattern examples?

2020-12-18 Thread frame via Digitalmars-d-learn
The manual often doesn't show the full potential of traits on the first sight or what they are really good for. But there are also all-day scenarios where I would just be happy for a quick lookup. For example, to assign a value to a class property which may have setter-overloads, I'm using a

Re: read till EOF from stdin

2020-12-11 Thread frame via Digitalmars-d-learn
On Friday, 11 December 2020 at 18:18:35 UTC, kdevel wrote: On Friday, 11 December 2020 at 16:49:18 UTC, Adam D. Ruppe wrote: libc-2.30.so The bug was fixed in 2.28 IIRC. so i guess i have the fixed libc. Can you confirm what version you have? Various. I tested the code on a machine

Re: Visual Studio with gtkD

2020-12-21 Thread frame via Digitalmars-d-learn
On Monday, 21 December 2020 at 17:34:45 UTC, RedshiftVelocities wrote: I'm trying to compile a gtkD program with VisualD. I've been following this guide (https://github.com/gtkd-developers/GtkD/wiki/Installing-on-Windows) and I can compile just fine directly from the command line. However, in

Re: C++ or D?

2020-12-23 Thread frame via Digitalmars-d-learn
On Saturday, 19 December 2020 at 09:06:33 UTC, Godnyx wrote: Hi! Can you be more specific about the problems someone is gonna face with D that can't be fixed? This is very important for me because I'm planning to use D for development in the near (I wish near) future and I want to know what's

Re: Slice allocation after appending

2020-12-23 Thread frame via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 11:19:38 UTC, Rekel wrote: I'm not sure what your aliasSeq does, sadly I don't find the documentation's explanation satisfactory. Try to write static foreach (arr; [a, b]) { .. } - it will not work because that loop is generated at compile time (static).

Re: read till EOF from stdin

2020-12-11 Thread frame via Digitalmars-d-learn
On Friday, 11 December 2020 at 12:34:19 UTC, kdevel wrote: My code cannot do that because the function byChunk has control over the file descriptor. What do you mean by control? It just has the file handle, why do you cannot call eof() on the file handle struct? You should not check

Re: read till EOF from stdin

2020-12-11 Thread frame via Digitalmars-d-learn
On Friday, 11 December 2020 at 02:31:24 UTC, kdevel wrote: auto s = cast (string) stdin.byChunk(4).join; As strace reveals the resulting program sometimes reads twice zero characters before it terminates: read(0, a <-- A, return "a\n", 1024)

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-07 Thread frame via Digitalmars-d-learn
On Saturday, 7 November 2020 at 12:29:46 UTC, Andre Pany wrote: Maybe mysql native is slower, but maybe this isn't the case, just the way performance measurements was done was incorrectly. I have tried mysql-native and it tooks way to long for simple things. My test setup is a remote linux

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-07 Thread frame via Digitalmars-d-learn
On Sunday, 8 November 2020 at 05:07:54 UTC, frame wrote: Something wrong with this library. Well, we need an edit function here. The library has no TCP_NODELAY flag enabled. This fix speeds it up to 10x and solves the 44ms problem to 400us

Re: asdf get first value from a json string.

2020-11-08 Thread frame via Digitalmars-d-learn
On Sunday, 8 November 2020 at 16:30:40 UTC, Vino wrote: Request your help on how to get the first value of "type" from the below json, the expected output required is as below, You need a data structure to work with, eg: static struct S { string characteristicValue; } foreach (ref j;

Re: asdf get first value from a json string.

2020-11-08 Thread frame via Digitalmars-d-learn
On Sunday, 8 November 2020 at 19:29:39 UTC, frame wrote: On Sunday, 8 November 2020 at 16:30:40 UTC, Vino wrote: Request your help on how to get the first value of "type" from the below json, the expected output required is as below, You need a data structure to work with, eg: static

Re: Is there a similar library to FreeMarker like in Java

2020-11-11 Thread frame via Digitalmars-d-learn
On Wednesday, 11 November 2020 at 08:13:23 UTC, Namal wrote: Hello, I want to do a small project but I need a text replacement tool/lib like Apache's FreeMarker. Is there something similar for D? Thx Maybe not so powerful but useful: mustache-d

Windows DLL Exception catching status?

2020-11-12 Thread frame via Digitalmars-d-learn
Is there still no way to catch an exception thrown from own DLL in main runtime?

Re: How can I wrap SSL on Dlang Socket?

2020-11-15 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 01:25:01 UTC, Marcone wrote: How can I wrap SSL on Dlang Socket like I wrap in Python? There is no functionality in the standard library. If you are just looking for a HTTP client, use std.net.curl. If you want your own thing or need a server application you

Re: Issue with opening files on VSCode "D Language utility extension pack"

2020-11-16 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 01:38:10 UTC, data pulverizer wrote: Hi All, On VS Code "D Language utility extension pack", I notice that if I open a random D file, on the bottom left of the IDE, a message says "D: workspace/(0.0%): starting up...". It stays at 0.0% and doesn't go away and

Re: Issue with opening files on VSCode "D Language utility extension pack"

2020-11-16 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 13:12:02 UTC, data pulverizer wrote: Not seeing an error in Developer Tools. I don't expect to because the loading sign remains there as if it is continuously trying to load and doesn't display any errors. You have to inspect the Console-Tab inside the

Re: Issue with opening files on VSCode "D Language utility extension pack"

2020-11-16 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 13:38:11 UTC, frame wrote: On Monday, 16 November 2020 at 13:12:02 UTC, data pulverizer wrote: Not seeing an error in Developer Tools. I don't expect to because the loading sign remains there as if it is continuously trying to load and doesn't display any

Can't pass [] to extern function object method

2020-11-16 Thread frame via Digitalmars-d-learn
I have a DLL in D-code which returns an object and want to pass a struct S[] to a member function of that object. The first element is passed correctly, the rest is just garbage. In fact the next item is just a single byte with value 0x11 following some 0x00. It doesn't matter if I'm using

Re: Can't pass [] to extern function object method

2020-11-16 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 21:58:44 UTC, Jack wrote: What is the function prototype like and how are you declaring that struct? The struct is very simple, it contains: struct S { SysTime a; ulong b; double c; ubyte[] d; string e; } And I tried: bool foo(S[] params);

Re: Calling function within class.

2020-11-19 Thread frame via Digitalmars-d-learn
On Thursday, 19 November 2020 at 19:51:24 UTC, Vino wrote: the moment we enable parallelism, it is throwing an error on the SQL part (Fetch the username/ password from the table for each account), as it could not execute the SQL query in parallel for different account. I see no reason for a

Re: Can't pass [] to extern function object method

2020-11-18 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 22:22:42 UTC, frame wrote: On Monday, 16 November 2020 at 21:58:44 UTC, Jack wrote: What is the function prototype like and how are you declaring that struct? The struct is very simple, it contains: I found the "bug". It was caused by a debug {} statement

Re: Calling function within class.

2020-11-18 Thread frame via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 15:01:53 UTC, Vino wrote: Hi All, Request your help on how to call a function(listFile) from another function(getFilelist) within the same class(GetDirlist), below is an example code. I think it's basically the same issue like that recently opened topic:

Re: Calling function within class.

2020-11-18 Thread frame via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 17:55:36 UTC, Vino wrote: I made the changes as below , still not working auto fltask = task!listFile(st); to auto fltask = task!({listFile(st);})(this).executeInNewThread(); The syntax is just wrong: auto fltask =

Re: Calling function within class.

2020-11-19 Thread frame via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 19:25:06 UTC, Vino wrote: The above code is a sample code, but the logic is same, correct me if my understanding is wrong, in the above code "obj" is a an object for the class GetDirlist, so we are accessing the class member using "obj.listFile(st)" , so

Re: Can't pass [] to extern function object method

2020-11-19 Thread frame via Digitalmars-d-learn
On Thursday, 19 November 2020 at 07:46:20 UTC, Bastiaan Veelo wrote: On Wednesday, 18 November 2020 at 10:50:12 UTC, frame wrote: I found the "bug". It was caused by a debug {} statement within a struct method. I assume that the debug symbol is just incompatible called from the DLL context.

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-06 Thread frame via Digitalmars-d-learn
On Friday, 6 November 2020 at 04:58:05 UTC, Vino wrote: Component : mysql-native + asdf Executable size : 17 MB Execution time : 10 secs, 189 ms, 919 μs, and 3 hnsecs Component : hunt-database + asdf Executable size : 81 MB Execution time : 5 secs, 916 ms, 418 μs, and 3 hnsecs Interesting

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-07 Thread frame via Digitalmars-d-learn
On Saturday, 7 November 2020 at 14:57:39 UTC, Vino wrote: After further analysis we suspect that the issue is at the package std.net.curl the flow of the program is as below Establishing a new connection may vary in duration of +200ms or more.

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-07 Thread frame via Digitalmars-d-learn
On Saturday, 7 November 2020 at 16:37:22 UTC, Vino wrote: , Trying to improve the above code hence request your help on how to use array container instead of array, tried as per the example below but not working. I think you can just use a static array as ubyte[1024] if you want a fixed

extern(C) Variant: attempting to use incompatible types int and int

2020-11-15 Thread frame via Digitalmars-d-learn
I know the problem that TypeInfo != TypeInfo in main and library context. Is there are a hack to get the data from the Variant even if the TypeInfo-check fails? I assume the only workaround is using an own struct or serializer to achieve the same functionality?

Re: How can execute method in new Thread?

2020-11-15 Thread frame via Digitalmars-d-learn
On Saturday, 14 November 2020 at 17:21:15 UTC, Marcone wrote: Error: D:\dmd2\windows\bin\..\..\src\phobos\std\parallelism.d(516): Error: struct `Fruit` does not overload () You can't. Because everything that can run in a new thread must be a (separate) function. If you are using an object

Re: isCallable fails

2021-01-20 Thread frame via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 13:11:09 UTC, Paul Backus wrote: On Wednesday, 20 January 2021 at 04:43:12 UTC, frame wrote: struct foo(T) { T get() { static if (is(T : bar)) { if (value is null) { value = fun!T; Error: template instance `fun!T` template

Re: isCallable fails

2021-01-20 Thread frame via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 19:01:19 UTC, frame wrote: It also compiles if value = new T enum R = isCallable!S throws: Error: cannot infer type from template instance isCallable!(data), possible circular dependency So that seems to be the problem. There is a circular dependency

Re: isCallable fails

2021-01-20 Thread frame via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 21:57:59 UTC, Paul Backus wrote: On Wednesday, 20 January 2021 at 19:01:19 UTC, frame wrote: Oh, look, it compiles with no errors. All that effort, and I *still* couldn't reproduce the issue you described in your original post. Guess I wasted my time for

Re: F*cked by memory corruption after assiging value to associative array

2021-01-25 Thread frame via Digitalmars-d-learn
On Monday, 25 January 2021 at 14:34:23 UTC, vitamin wrote: Is the object returned from dll GC allocated? The object is created on the default way. No alternating allocation. Before the object is returned it's added to GC.addRoot() which should be enough but may I'm wrong. I also tried to

Re: F*cked by memory corruption after assiging value to associative array

2021-01-25 Thread frame via Digitalmars-d-learn
On Monday, 25 January 2021 at 16:54:42 UTC, vitamin wrote: On Monday, 25 January 2021 at 16:44:40 UTC, frame wrote: On Monday, 25 January 2021 at 16:14:05 UTC, vitamin wrote: [...] Yes with simple new operator. Forgot to mention: the DLL itself calls a DLL. [...] If there are separated

Re: F*cked by memory corruption after assiging value to associative array

2021-01-25 Thread frame via Digitalmars-d-learn
On Monday, 25 January 2021 at 16:14:05 UTC, vitamin wrote: If created on the default way mean allocated with new (=> GC) then I don't known where is problem, but if the object is allocated with other way, for example malloc, some allocator then you need tell GC about that object with

Re: Why filling AA in shared library freezes execution?

2021-01-26 Thread frame via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 06:53:22 UTC, Vitalii wrote: It's quite unexpected for me that nobody give me some help about usage of AA in shared library. Nobody use shared library? Nobody use AA? Post with trivial questions about OpAssign gets many answers. Even post about changing logo

Re: isCallable fails

2021-01-21 Thread frame via Digitalmars-d-learn
On Friday, 22 January 2021 at 00:59:32 UTC, tsbockman wrote: Generally, I don't need to know what causes an error in order to produce an MCVE. I have successfully done so on many occasions. It's annoying and slow, but usually very possible. I know that I have to debug it myself, but if

Re: isCallable fails

2021-01-21 Thread frame via Digitalmars-d-learn
On Friday, 22 January 2021 at 02:43:44 UTC, tsbockman wrote: No, we're just used to helping each other get to the bottom of things like this. No one asked you for anything different from what we generally expect of each other in this context. This specific expectation mostly exists because,

Re: isCallable fails

2021-01-21 Thread frame via Digitalmars-d-learn
On Friday, 22 January 2021 at 03:40:40 UTC, tsbockman wrote: Cars are mass-produced copies of a relatively small number of rather similar designs, and mechanics' customers *pay them* to understand and fix their cars so that the customers don't have to. I knew this argument comes...

isCallable fails

2021-01-19 Thread frame via Digitalmars-d-learn
What could cause the following error? Error: expression isCallable!(data) of type void does not have a boolean value Problematic lines are: // T = some class // S = "data" (data is member of T) // typeof(S) = some struct U!X, not void alias S = __traits(getMember, T,

Re: isCallable fails

2021-01-19 Thread frame via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 01:07:15 UTC, Ali Çehreli wrote: I may know the answer but I can't be sure because you don't provide code that reproduces the issue. I am trying to write code below according to your description but it's really tough. Can you reproduce the issue please. // T

F*cked by memory corruption after assiging value to associative array

2021-01-25 Thread frame via Digitalmars-d-learn
After a while my program crashes. I'm inspecting in the debugger that some strings are overwritten after a struct is assigned to an associative array. - I have disabled the GC. - All happens in the same thread. - The strings belong to an object collection inside an object created from a

Re: Dll crash in simplest case

2021-01-25 Thread frame via Digitalmars-d-learn
On Monday, 25 January 2021 at 07:58:01 UTC, Vitalii wrote: Hello everyone! I want to create shared library that buffer some data and do some calculations, another program will use it. I wonder how this simplest code lead to crash (freeze) of dll: Not tested your code but you have to use

Re: Dll crash in simplest case

2021-01-25 Thread frame via Digitalmars-d-learn
On Monday, 25 January 2021 at 11:30:45 UTC, Vitalii wrote: --- Dll is starting ok. But after freeze after printing number around 64000 (~2^16). When I change assoc.array to simple array of double[] it freeze after number around 52 (~2^19), int[] -- 1.000.000. So I conclude than dll

Re: F*cked by memory corruption after assiging value to associative array

2021-01-25 Thread frame via Digitalmars-d-learn
On Monday, 25 January 2021 at 11:25:56 UTC, FeepingCreature wrote: I suspect the memory used by the original data got reused for the associative array somehow. But if the GC is off from program start, that should really not occur. Do you maybe turn the GC off before the AA assignment, but

Re: Tuple enumeration without integers or strings

2021-01-01 Thread frame via Digitalmars-d-learn
On Saturday, 2 January 2021 at 00:57:48 UTC, Paul wrote: So this neither seems a satisfiable solution to me :/ Couldn't you just use Wind.N.hashOf and a custom format() expression for string-representation?

Re: What is the difference between "delegate()" and "lazy delegate()" ?

2021-01-02 Thread frame via Digitalmars-d-learn
On Saturday, 2 January 2021 at 12:29:43 UTC, Marcone wrote: Why "lazy delegate()" need two parentheses to execute function? AFAIK is 'lazy' some kind of delegate storage class which accept an expression to execute. The reason you can actually use the parameter without "()" is just CTFE sugar

Re: Tuple enumeration without integers or strings

2021-01-02 Thread frame via Digitalmars-d-learn
On Sunday, 3 January 2021 at 01:15:56 UTC, Paul wrote: On Saturday, 2 January 2021 at 21:48:04 UTC, Paul Backus wrote: Yes, but this will be true of any approach you choose. If two enum members have exactly the same value, there is no way to distinguish between them, either at compile time or

Re: Tuple enumeration without integers or strings

2021-01-02 Thread frame via Digitalmars-d-learn
On Sunday, 3 January 2021 at 04:16:20 UTC, Paul Backus wrote: On Sunday, 3 January 2021 at 02:41:12 UTC, Paul wrote: hashOf is not guaranteed to produce unique values, so I would not advise using it here. Of course it's a hashing method but also internally used for comparison and good

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 12:42:09 UTC, Siemargl wrote: Update. Something is broken in DLL support in druntime for Win7. I take previous working in Win10 binary and try run it in virtual Windows 7 SP1 x64. Got this You can't expect that a Win10 build also runs on Win7.

Re: What are these functions called and how to implement they?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 17:10:57 UTC, dog2002 wrote: I saw these functions in some projects. For example: in Dagon (https://gecko0307.github.io/dagon/) there are functions like onKeyDown. This function doesn't need to call - it checks pressed keys every time. Or Update in Unity (game

Re: F*cked by memory corruption after assiging value to associative array

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 19:22:16 UTC, tsbockman wrote: It is possible to get things sort of working with on Windows, anyway. I'm ok with it as long as the memory is not re-used by the GC. It seems that it can be prevented with addRoot() successfully. The other problem with shared

Re: Why filling AA in shared library freezes execution?

2021-01-26 Thread frame via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 11:17:11 UTC, Vitalii wrote: I'll be waiting for bugfix release. There could also be other reasons if your system is "compromised" by a Hijack-DLL thats automatically included when your app starts by an Anti-Virus scanner or some bug in a C++ updated or

Re: Can I set the base class like this?

2021-01-26 Thread frame via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 04:39:07 UTC, Jack wrote: note the body is the same, what changes is the base class. I'd like to avoid repeating myself when the body is the same and only the base class changes. You would have to call it with correct instantiation like alias Foo = C!(A!bool);

Re: F*cked by memory corruption after assiging value to associative array

2021-01-26 Thread frame via Digitalmars-d-learn
On Monday, 25 January 2021 at 17:11:37 UTC, frame wrote: Wrong way? Please, someone correct me if I'm getting this wrong: Structure: EXE/Main Thread: - GC: manual - requests DLL 1 object A - GC knows about object A DLL/Thread 1: - GC: conservative - allocates new object A -> addRoot(object

Re: F*cked by memory corruption after assiging value to associative array

2021-01-27 Thread frame via Digitalmars-d-learn
On Tuesday, 26 January 2021 at 14:31:58 UTC, frame wrote: but why does not see DLL 1 then that sub objects of B are still alive? I may fool myself but could it be caused by an already gone slice data? It very looks like that only a specific string property is corrupted which got the same

Re: F*cked by memory corruption after assiging value to associative array

2021-01-27 Thread frame via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 17:41:05 UTC, Ali Çehreli wrote: On 1/26/21 6:31 AM, frame wrote: > all GCs Multiple D runtimes? That might work I guess but I've never heard of anybody talking about having multiple runtimes. Does rt_init() initialize *a* D runtime or *the* D runtime? If it

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 07:51:06 UTC, SealabJaster wrote: On Wednesday, 27 January 2021 at 16:38:07 UTC, Adam D. Ruppe wrote: ... Yikes! Ok, I thought DLLs were just "sort of" unusable due to the RTTI issue, but now I'm convinced that they're almost completely useless in their

Re: F*cked by memory corruption after assiging value to associative array

2021-01-27 Thread frame via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 22:57:11 UTC, tsbockman wrote: There is supposed to only be one instance of the D GC running per process. If you have more than one running then either you aren't linking and loading the DLLs correctly, or you have run into a serious bug in the D tooling.

Re: What are these functions called and how to implement they?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:27:09 UTC, frame wrote: Not 100% sure what you mean but I guess you ask how to implement a handler? If an event occurs, a routine decides to call your onKeyPressed function and pass the keyCode which was pressed. The routine must be registered on a event

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 17:00:35 UTC, Siemargl wrote: On Thursday, 28 January 2021 at 16:46:40 UTC, frame wrote: On Thursday, 28 January 2021 at 12:42:09 UTC, Siemargl wrote: Update. Something is broken in DLL support in druntime for Win7. I take previous working in Win10 binary and

Minimize GC memory footprint

2021-01-30 Thread frame via Digitalmars-d-learn
Is there a way to force the GC to re-use memory in already existing pools? I set maxPoolSize:1 to gain pools that can be quicker released after there no longer in use. This already reduces memory usage to 1:3. Sadly the application creates multiple pools that are not necessary in my POV -

Re: Minimize GC memory footprint

2021-01-30 Thread frame via Digitalmars-d-learn
On Saturday, 30 January 2021 at 22:57:41 UTC, Imperatorn wrote: On Saturday, 30 January 2021 at 16:42:35 UTC, frame wrote: Is there a way to force the GC to re-use memory in already existing pools? I set maxPoolSize:1 to gain pools that can be quicker released after there no longer in use.

Re: F*cked by memory corruption after assiging value to associative array

2021-01-29 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 22:11:40 UTC, tsbockman wrote: Alternatively, you can design your APIs so that no pointer to GC memory is ever owned or mutated by any thread unknown to that GC. (This is the only option when working across language boundaries.) Yes, thank you for your input

Re: Why filling AA in shared library freezes execution?

2021-01-29 Thread frame via Digitalmars-d-learn
On Friday, 29 January 2021 at 01:23:20 UTC, Siemargl wrote: On Friday, 29 January 2021 at 00:45:12 UTC, Siemargl wrote: Then i modify program, just removing DLL, copying TestFun() in main module and it runs. Same compiler -m64 target. Ups. Sorry, I just forget copy test_dll.dll inside VM

Re: Minimize GC memory footprint

2021-02-03 Thread frame via Digitalmars-d-learn
On Sunday, 31 January 2021 at 12:14:53 UTC, Imperatorn wrote: It says experimental, but it's fine: https://dlang.org/phobos/std_experimental_allocator.html Well, this looks very nice but I have to deal with GC as long I want to use other libraries that are relying on it or even just

Re: Can change vtbl record at runtime ?

2021-02-03 Thread frame via Digitalmars-d-learn
On Wednesday, 3 February 2021 at 05:30:37 UTC, Виталий Фадеев wrote: Reason: Reuse component, bind custom callback without creating new class. Concept example: class SaveFilePopup { void onSuccess() { /* default operations */ } } auto saveFile = new

Re: What exactly gets returned with extern(C) export string func() ?

2021-06-16 Thread frame via Digitalmars-d-learn
On Wednesday, 16 June 2021 at 02:46:36 UTC, cc wrote: I can't seem to get it to work as a return type, but interestingly it does work as an out/pass by ref parameter. Probably for returning the struct it needs some allocation directive in C# but I'm not sure. Maybe C# also tries something

Re: how do i fix this node_dlang error?

2021-06-07 Thread frame via Digitalmars-d-learn
On Monday, 7 June 2021 at 02:33:38 UTC, Jack wrote: What am I missing? If this runs under Windows, there is no dlopen(), maybe a wrapper to LoadLibrary() but this will need to call a DllMain() in the DLL if I am not wrong. Is there a DllMain?

Re: What exactly gets returned with extern(C) export string func() ?

2021-06-13 Thread frame via Digitalmars-d-learn
On Sunday, 13 June 2021 at 10:02:45 UTC, cc wrote: it seems to work as expected with the same C# code. Does D explicitly disallow slices as an extern(C) export parameter type? The spec says that there is no equivalent to type[]. You get a type* instead.

Re: is there a way to: import something = app-xyz-classes-something; ?

2021-06-21 Thread frame via Digitalmars-d-learn
On Monday, 21 June 2021 at 13:29:59 UTC, Steven Schveighoffer wrote: It does work. However, you have to tell the compiler the file to compile. Which completely ignores filenames if the compiler is satisified. You may assume by reading the manual that the compiler would make an automatic

Re: do I incur a penality on compile time if I explicitly declare default behavior ?

2021-06-22 Thread frame via Digitalmars-d-learn
On Monday, 21 June 2021 at 22:56:30 UTC, someone wrote: This might happen even though you wrote the actual type at the time -- sometimes library code changes the type, and just uses alias this to allow original code to compile. For what I was reading a couple of days ago while navigating

Re: is there a way to: import something = app-xyz-classes-something; ?

2021-06-21 Thread frame via Digitalmars-d-learn
On Monday, 21 June 2021 at 03:32:58 UTC, someone wrote: Since memory serves I use to name files with - instead of the more common _ The module name has to be strict and "-" is not allowed. However, you should be able to import files with a "-" in the name. From the manual: If the file name

Re: do I incur a penality on compile time if I explicitly declare default behavior ?

2021-06-21 Thread frame via Digitalmars-d-learn
On Monday, 21 June 2021 at 04:12:55 UTC, someone wrote: I mean, coding as following: Even if it would have an impact - it may change with a new compiler release. I personally use explicit declaration in a foreach loop, because the IDEs don't get the type and it cost me more time to figure

Re: how to filter associative arrays with foreach ?

2021-06-21 Thread frame via Digitalmars-d-learn
On Monday, 21 June 2021 at 03:59:10 UTC, someone wrote: I often need to iterate through a filtered collection (associative array) as following: ```d string strComputerIDunwanted = "WS2"; /// associative array key to exclude foreach (strComputerID, udtComputer; udtComputers) { ///

Re: Flaoting point operations : unexpected results

2021-06-11 Thread frame via Digitalmars-d-learn
On Thursday, 10 June 2021 at 20:18:03 UTC, seany wrote: On Thursday, 10 June 2021 at 19:51:51 UTC, Dennis wrote: On Thursday, 10 June 2021 at 19:37:36 UTC, seany wrote: However, i sometimes see, that the results are _radically_ different. Are you using uninitialized memory or

Filter for opDispatch?

2021-05-14 Thread frame via Digitalmars-d-learn
When using opDispatch() - how can I tell the compiler that I do not want to handle some calls? Some code is testing for range methods (empty, front, popFront) and I don't know where and which side effects it causes. - how can I dismiss calls from __traits(compiles)?

Re: Filter for opDispatch?

2021-05-14 Thread frame via Digitalmars-d-learn
On Friday, 14 May 2021 at 22:39:29 UTC, frame wrote: When using opDispatch() Thanks! I stumbled around with static asserts and mixins... totally forgot about the constraints but they will to the trick.

Re: Filter for opDispatch?

2021-05-15 Thread frame via Digitalmars-d-learn
On Sunday, 16 May 2021 at 03:19:04 UTC, Mike Parker wrote: On Sunday, 16 May 2021 at 00:04:39 UTC, frame wrote: Yes, but why should the derived class not have access to it? I don't think that's your problem. From the template docs: _TemplateInstances_ are always instantiated in the scope

Re: Filter for opDispatch?

2021-05-15 Thread frame via Digitalmars-d-learn
On Sunday, 16 May 2021 at 04:38:52 UTC, Mike Parker wrote: On Sunday, 16 May 2021 at 04:07:15 UTC, frame wrote: But the same with fields work? They are also protected. I'm not sure what you mean by "fields" here. ```d protected: // inaccessible /* void s(int v) { _s = v; } int s() {

Re: Filter for opDispatch?

2021-05-15 Thread frame via Digitalmars-d-learn
On Friday, 14 May 2021 at 23:02:22 UTC, frame wrote: Thanks! I stumbled around with static asserts and mixins... totally forgot about the constraints but they will to the trick. Now I run into the error "class Foo member s is not accessible" "template instance Base.opDispatch!("s", int, Foo)

Re: Filter for opDispatch?

2021-05-15 Thread frame via Digitalmars-d-learn
On Saturday, 15 May 2021 at 23:59:49 UTC, Paul Backus wrote: On Saturday, 15 May 2021 at 23:41:19 UTC, frame wrote: On Friday, 14 May 2021 at 23:02:22 UTC, frame wrote: Thanks! I stumbled around with static asserts and mixins... totally forgot about the constraints but they will to the

Re: struct destructor

2021-05-20 Thread frame via Digitalmars-d-learn
On Sunday, 16 May 2021 at 11:42:19 UTC, Adam D. Ruppe wrote: On Sunday, 16 May 2021 at 08:04:06 UTC, cc wrote: I tracked down the problem but wasn't 100% sure about the fix. Adding the GC.baseOf thing works for me but i didn't upstream since idk if it works for everyone else. maybe i

How long does the context of a delegate exist?

2021-05-27 Thread frame via Digitalmars-d-learn
I'm using a buffer delegate to fill data from a DLL and use it as range like this: Pseudo-Code: ```d void DLLFun(out Collector collector) { auto something; collector = Collector(...); collector.registerFillBufferMethod({ auto data = []; //... // use of something;

Re: How long does the context of a delegate exist?

2021-05-27 Thread frame via Digitalmars-d-learn
On Thursday, 27 May 2021 at 16:17:12 UTC, Alain De Vos wrote: I think of a dynamic array as a value-type consisting of a pointer to the actual data and a length, which gets copied. The data pointing to will continue to live. The pointer and length might disappear from the stack or get copied.

  1   2   3   4   >