« first day (4245 days earlier)      last day (696 days later) » 

1:19 AM
@mr5 still, you'd have to write a lot of code for that
 
 
1 hour later…
mr5
2:27 AM
@Wietlol nope (assuming you are using STJ of course)
var obj = JsonSerializer.Deserialize<YourType>(Fields);
for(var prop in obj.GetType().GetProperties()) {
	var value == prop.GetValue(obj, null)
	if (value == null) {
		throw ...
	}
}
 
 
2 hours later…
 
2 hours later…
6:44 AM
[Squirrel in Training] GoOoOoOoOoOoOoOoOoOoOoOd Mornin' neglecterinos!
 
Good morning
@mr5 I feel like STJ has an option for that somewhere in the deserialiser.
 
 
3 hours later…
9:29 AM
@mr5 except some properties are actually nullable
 
9:49 AM
looking on this code Im excited to make it one line
my colleague might not happy with that
 
10:23 AM
await Task.Run(() => {
    // put all that long code here
});
tada, you can now make everything a one liner
 
// put all that long code here

suffices
 
return TheCodeIsAllHere();
 
int just; int a; int one; int liner;
 
Ctr+H -> search: \r?\n (mark the regex option) -> replace: <single space> -> click Replace All
 
 
2 hours later…
12:38 PM
Yo
 
Hello
I need help quickly from some .NET Dev (I am a dev myself)
Here I have a web application on which I changed .NET 5 TargetFramework in .NET 6, which is running fine on a IIS Server with a .NET 5.0.6 Runtime install. How this is possible? Shouldn't it require .NET 6 installed on the server?
Basically I can deploy the Asp.NET MVC application using .NET 6 in a IIS Server where .NET5 is installed
and it works....
Shouldn't be .NET 6 be required or throw some error?
 
Got this annoying message: "type or namespace name does not exist in the namespace.."
 
@EdGzi Should be more specific on where it happens
 
I deleted the file, which is ok.. but in app.g.cs it's still has reference to the old file "using App.SomeFile"
 
@EdGzi Clean solution and .vs hidden folder
 
12:40 PM
delete the .vs folder?
 
projects have a hidden .vs folder in them
when something goes wrong, it's common to delete it if it's some leftover file or similar trash
 
I'll keep that in mind
 
make a try. Vs automatically recreate t
*it
you are not going to lose anything
 
[del] button?
 
I cleaned.
Then I deleted the vs folder
Same error
 
12:44 PM
what is the type or namespace you are trying to reference?
 
1:00 PM
It's a folder
That I deleted
I don't need it
 
but you still reference it
> but in app.g.cs it's still has reference to ...
 
I removed all the references, however.. in the App.g.cs it's still referenced.
 
what stops you from removing the reference in App.g.cs?
 
I do not wish to touch the file as the comment mentions the following: `//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------`
 
what if you re-genereate it?
 
1:02 PM
how can I do that?
 
iDunno
 
:(
 
> This code was generated by a tool.
 
I'll figure it out, i'll update once i got an answer
 
unless the tool is named "a tool", I find the comment hardly useful
most code generators specify who genrerated the file
but I suppose you can just edit it and everything will work
afaik, only my own code generators have hash checks to assert that the code hasnt been altered
 
1:04 PM
[Hector] morning
[Hector] or rather, afternoon
[Hector] today I'm stuck with a GDI memory leak, wish me luck 😄
[Hector] apparently if I do using(Bitmap temp = new Bitmap....)mybitmap=temp it will crash because mybitmap, which is a private object belonging to the class, gets destroyed along with its reference, like this was JS or some shit
[Hector] for reference
\[**[Hector](https://discord.gg/PNMq3pBSUe)**] ` using (this.screenshot = CaptureApplication(process))
{



// TODO: It's not this function's business to update the UI
this.Dispatcher.Invoke(() =>
{
IntPtr screenshotHandle = this.screenshot.GetHbitmap();
imgBluestacks.Source = Imaging.CreateBitmapSourceFromHBitmap(
screenshotHandle,
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromWidthAndHeight(screenshot.Width, screenshot.Height));
});
#if DEBUG
screenshot.Save(Path.Combine(new[] { WorkingDirectory, "screenshot.bmp" })); // DEBUG
[Hector] this works as an isolated function
[Hector] if I replace the top line with a new bitmap, it also works, like this:
\[**[Hector](https://discord.gg/PNMq3pBSUe)**] ` using (Bitmap tempBitmap = CaptureApplication(process))
{
this.screenshot = tempBitmap;`
[Hector] after i get out of the using block, the bitmap is destroyed, and all objects assigned to this variable return exceptions
[Hector] i don't want to dump it to disk every time because that will burn it, and it's slower than working in memory
 
1:20 PM
@Wietlol Nah tried that before.. screwed everything up
 
@Hector you should dispose objects when you are done using them
clearly, you dispose of them too early
 
[Hector] well, the problem is, when I don't dispose them, I see memory climb fast. When I dispose them, they break something unrelated
[Hector] to put it simple
\[**[Hector](https://discord.gg/PNMq3pBSUe)**] `Bitmap temp = new Bitmap(...);
this.bitmap = temp;
temp.Dispose();

// bitmap: Exception was thrown`
[Hector] I want to store the bitmap and dispose the middle step
 
you have to do all the processing in the correct place
var screenshot = CaptureApplication(process);

#if DEBUG
screenshot.Save(Path.Combine(new[] { WorkingDirectory, "screenshot.bmp" })); // DEBUG
#endif

this.Dispatcher.Invoke(() =>
{
	using (screenshot)
	{
		// do the thing
	}
};
this should work if you dont use the screenshot anywhere else
if you do, you need to keep track of where it still needs to be used before disposing of it
or how many times it is still in use
which can easily be done by a wrapper class
the class field makes it more difficult though
 
so if you can, you should remove the field
 
1:30 PM
[Hector] oh damn i just learnt you can do that
 
do what?
send empty messages in SO chat?
 
[Hector] in Discord it shows just fine
IDK how it translates to SOchat if I do this:
1
2
3
[Hector] do you see the numbers?
 
ye
 
[Hector] there we go, much easier to read
[Hector] I can't read my previous code
[Hector] IDK how your code is different than mine
[Hector] all you did was move the debug function 1 step ahead
 
yea, you do, you just have to try harder
I did more things
 
1:35 PM
[Hector] oh the using in the invoke
 
yes
 
[Hector] does it actually make sense to put a private property inside a using block?
[Hector] also it makes the code more spaghetti
Why not this:
            if (this.screenshot != null)
            {
                this.screenshot.Dispose();
            }
[Hector] before the assignment
[Hector] btw that doesn't work, I still have a leak
[Hector] Would you like me to add you to the project so you can clone it and see what's going on? There are probably a bunch of things that I didn't explain and are relevant to this scenario
 
@Botler concurrency
you shouldnt have a memory leak by the screenshot if you dispose it
 
[Hector] IDK if that's the point where the leak occurs
[Hector] I have no way to trace it
[Hector] I ahve this other piece of code that builds the Bitmap. I believe it could be another issue. Any idea how can I trace where the leak is
 
1:54 PM
[Squirrel in Training] Sorry no, but i know not to trust wietl0l
[Hector] well it definitely is a leak on the screenshot. I launched it on a loop and it's up to 1.5gb in 20 seconds
 
2:18 PM
[Hector] all those jetbrain tools are paid commercial software
[Hector] only dotpeek is free, and it won't tell me where my memory leak is
 
@Wietlol found the problem finally..
In my App.xaml I had a reference set up to the deleted folder.
 
oh ye, I forget that the software I use is often paid :D
@Hector, what is the current code?
if you did the disposing properly, and it always runs the dispatched code, it should work fine
you could move the creation of the screenshot into the dispatched code as well perhaps
 
[Hector] <@211519661420838912>
[Hector] I have a firm belief the error is there
[Hector] it's weird, if I do it slowly, I don't see an increase in memory usage
[Hector] feels like there's a problem about the process running too fast
 
2:34 PM
> concurrency
> if you can, you should remove the field
this is also a very important thing that I changed
you are running concurrent code with mutating models
that is #1 rule of what not to do
 
[Hector] memory spike when creating the graphics
[Hector] there's the leak
[Hector] took forever pressing F10 without skipping
 
2:48 PM
only thing I can recommend is using a good tool to trace your memory usage and sources
 
3:15 PM
[Hector] it's weird because GC won't collect anything anyway
 
3:30 PM
that is why it is called a leak
if the GC would just clear it, then no one would bother
except for C maniacs
 
[Captain Obvious] oooh hwat's going on here
[Captain Obvious] the GC doesn't clear it because it's unmanaged memory that you're leaking. However, from my experience at least, while the application does not free the memory for the system (at least not without some magic), it does seem to be aware when it tries to allocate more (maybe on a subsequent call to the same method) that there is some unmanaged memory that the application already has access to which isn't being used
[Captain Obvious] Though this is from .net 4.6, if you're using core then you could be in a completely different world
[Hector] yup
[Hector] well it's framework 4.7.2
 
4:04 PM
[Captain Obvious] That's close enough
 
 
6 hours later…
9:47 PM
[Hector] <@211519661420838912> and everyone else interested, I found the culprit. Apparently there's no memory leak, it's the fact that I create and destroy GDI objects so fast that they start fragmenting the heap so fast that the GC can't compact and collect them, because they are scattered all over the place.
[Hector] They say the best way to handle this would be to create memory pools manually and handling it
 
10:53 PM
Sorry for the disturbance, I'm looking for a C language chat room and the chat search is not really powerful enough. I lucked into this by guessing that it might be a low room number... is there one for C? Do you have a link?
sorry, I found it from the tag wiki, never mind :)
 

« first day (4245 days earlier)      last day (696 days later) »