TldrOlli
TldrOlli
CC#
Created by YetAnohterOne on 2/6/2025 in #help
CA1860: Avoid using 'Enumerable.Any()' extension method
OOO
59 replies
CC#
Created by Jacko on 2/3/2025 in #help
Question about Dependency Injection:
Out of curiosity what’s the benefit of using the IServiceCollection interface over just the autofac container? I’m using spectre cli which lets me register any DI system so wasn’t sure if it was just for generic host support
There is no benefit you are looking for, I guess. IServiceCollection is a very general interface that handles registrations, nothing more. It depends on the actual container (framework) that is used behind the scenes. If you are, for example, in a Asp.Net project, then you would want to use the IServiceCollection instance, mainly because all the framework registrations also go there (so it prevents you from having a completely seperate ioc container). You can define the fwk to use for DI at startup.
some of the features like xml configuration for loading in interfaces could be useful to adapt the project for different businesses that might use different log systems
Have a look at IConfiguration here, things like that are possible with the standard container.
I’m also looking into the decorator pattern autofac supports for implementing logging and other features on some interfaces provided by other libraries
AoP is certainly something that the M.E.DI container does not support, but you could make it work together with Castles Dynamic Proxy. But at that point.. it makes more sense to use something others built already for you. To be clear: I don't have anything against AutoFac, there are certainly use cases for it. Usually you just don't need it unless you want something quite nieche. I'm a bit an DI enthusiast and I had to use it only once so far, where the standard container was not sufficient. 🙂
74 replies
CC#
Created by Jacko on 2/3/2025 in #help
Question about Dependency Injection:
I've recently added something similar based on Microsoft.Extensions.DependencyInjection, I'm guessing you are looking for something roughly like this. For that, there is no need to use AutoFac, just be aware that the Assembly in question must be loaded, otherwise you will not find any types populated. While I agree with @TeBeCo, there are use cases for AutoFac, even when you are using the IServiceCollection interface (there is a neat adapter for it). For example AutoFac has support for tenant-specific containers, i.e. resolving different services based on some kind of tenant-identification (see here, but that only as a side note)
74 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
So.. After updating the AMD graphic card driver the memory leak is gone. What the heck. I apologize and thanks a lot for your help! 🙂
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
No description
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
Welp.. Having it running for3 hours on the dev machine now.. there is no sign of perf. degredation or any memory leak (╯°□°)╯︵ ┻━┻ I guess I'll deploy it as a service here too, to be sure.. Somehow I start feeling like my target (mini-pc/192.168.178.50) is the one causing the trouble.. as in: It's depending where it runs
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
I don't have VS, but let me see how far I can get with dotmemory.
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
No description
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
No description
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
Mh, opentel doesn't like the metric (same for max).. I took a look here and other places.. My best guess would be that my otelcol-contrib is not up-to-date enough (installed yesterday :/)

Jan 30 05:43:28 kali.acaad otelcol-contrib[3376]: 2025/01/30 05:43:28 collector server run finished with error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding:
Jan 30 05:43:28 kali.acaad otelcol-contrib[3376]: * error decoding 'receivers': error reading configuration for "hostmetrics/system": error reading settings for scraper type "memory": 1 error(s) decoding:
Jan 30 05:43:28 kali.acaad otelcol-contrib[3376]: * 'metrics' has invalid keys: system.linux.memory.available

Jan 30 05:43:28 kali.acaad otelcol-contrib[3376]: 2025/01/30 05:43:28 collector server run finished with error: failed to get config: cannot unmarshal the configuration: 1 error(s) decoding:
Jan 30 05:43:28 kali.acaad otelcol-contrib[3376]: * error decoding 'receivers': error reading configuration for "hostmetrics/system": error reading settings for scraper type "memory": 1 error(s) decoding:
Jan 30 05:43:28 kali.acaad otelcol-contrib[3376]: * 'metrics' has invalid keys: system.linux.memory.available
Edit: Tried multiple versions, current log is wrong.. one sec Edit2: Fixed Config:
memory:
metrics:
system.memory.utilization:
enabled: true
system.linux.memory.available:
enabled: true
memory:
metrics:
system.memory.utilization:
enabled: true
system.linux.memory.available:
enabled: true
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
No description
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
No description
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
I will prepare that now and run it once I see the memory consumption go up in the windows service (above version) Maybe (not too optimistic) the above change already fixes my leak.. But still my question: If the Process itself would be incorrectly handled (not disposed), wouldn't I see that in the managed memory?
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
No description
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
I am not too much optimistic about it though.. But just to be on the safe side that it's not caused by either the library or by incorrect usage of Process.
34 replies
CC#
Created by Cyclomatic on 1/29/2025 in #help
IoC and messy factory methods
As long as your extension methods use IServiceCollection to register your services you are good to go.
25 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
Thanks a ton!
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
Ah - so that explains why sometimes the command would block forever. I guess I'll give it a shot with proper disposal and (for now) only reading from StdOut
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
I found an older state here and I'm fully aware that the using/dispose is missing in that state. I did add it and let it run for a while (with the disposal), but had no luck. However, maybe it's worth a shot retrying just plain Process with all the other noise (thousands of CTS recreations) gone
34 replies
CC#
Created by TldrOlli on 1/29/2025 in #help
✅ Process API: Memory Leaks in Windows (?)
Yep.. Well, I did.. CliWrap's Process is not disposable. As far as I can tell from going through the libraries source code the Process is disposed as expected. In any case, wouldn't this, without being correctly disposed, show up as increasing managed memory (see dashboard above) Edit: Trying to find the last version that still used Process for reference Edit2: Squash merge ftw :/
34 replies