IT/Software career thread: Invert binary trees for dollars.

Vinen

God is dead
2,789
495
Isn't that kinda what I'm saying? You wouldn't have to know about 'using' as a best practice if garbage collection's scope cleaned up this particular problem for you.

I guess I'm just confused as to why you wouldn't want to know the scope level of the language you're using. I went into this job assuming Python's scope level was the same as Java's. It isn't. After that was clarified, it certainly made understanding existing code much easier.
The whole point is that you are taught the coding practice of using... using statements whenever using an object which implements IDisposible.

USING USING USING USING...
 

Lendarios

Trump's Staff
<Gold Donor>
19,360
-17,424
Items on managed memory get cleaned up when there are no pointers that accesses it. That is the rule of thumb for the GC.

Sort of a two list system, first list is the list of pointers to a memory address of something. Second list is the actual memory address range.(your data is located in those addresses)

When you create a variable it goes to both lists, first list is the pointer saying where your data is, and the second list is the memory address that contains your data. Whenever variables go out of scope, the pointer is removed from the first list, the data is kept on memory occupying memory space.

Periodically the GC looks at the second list and deletes the records from that list that don't have a pointer on list A pointing to it. This process actually frees up memory

It bears some similarity to a FAT table and file data.
Deleting does not deletes the data, is simply removes the record from the fat table, the data is still there.
 

Tenks

Bronze Knight of the Realm
14,163
607
Deleting does not deletes the data, is simply removes the record from the fat table, the data is still there.
Aka a logical delete. Which is pretty standard practice in many systems since its quicker to just tombstone something then delete it for real later.
 

Tuco

I got Tuco'd!
<Gold Donor>
46,830
78,452
I'll let you know if it's some idisposable that wants to be in using blocks. I hate when I run into C# code that has code embedded in multiple levels of using.
 

Tuco

I got Tuco'd!
<Gold Donor>
46,830
78,452
If you have multiple levels of using you are probably writing your methods incorrectly and in an untestable manner.

BTW:.net - Nested using statements in C# - Stack Overflow
Not sure if you're recommending the top recommendation there:
using (StreamReader outFile = new StreamReader(outputFile.OpenRead:)emoji_nose:
using (StreamReader expFile = new StreamReader(expectedFile.OpenRead:)emoji_nose:
{
///...
}


Or suggesting an explosion of functions to reduce the nested size by transferring it to the call stack, but either way this is the kind of programming argument I don't really care either way about. I like managing my own memory like an old man yells at clouds.
 

Tuco

I got Tuco'd!
<Gold Donor>
46,830
78,452
What about,

How is that memory leak treating you?
Not bothering me in the least! At this point I think you've spent more time on it than I have! It's most likely some dumb shit I'm doing.

I think that type of using only works if all the elements are the same.
 

Vinen

God is dead
2,789
495
Not bothering me in the least! At this point I think you've spent more time on it than I have! It's most likely some dumb shit I'm doing.

I think that type of using only works if all the elements are the same.
Yep, has to be the same type. I'm not sure about the one I linked. I don't like how it looks and it likely works the same way as this.
 

Kharza-kzad_sl

shitlord
1,080
0
I struggled with C# memory stuff for awhile. I couldn't believe there was no memcpy etc.

Most of my leaks have been events. Like if you have an objectA with an event and another objectB registers on it, nulling objectA won't free it until objectB unregs the event.

Also if you have alot of small structures or classes that get created and destroyed alot, use a pool class to reuse the memory. In my precomputed visibility stuff it got me huge gains just by not bloating up the garbage and eating up cpu cleaning it up.
 

Noodleface

A Mod Real Quick
38,245
15,030
Well a month of basically getting changing requirements every hour (seriously, back and forth back and forth), we were finally able to release a production BIOS for one server SKU.

The way things were done here really has me scratching my head.
 

Tuco

I got Tuco'd!
<Gold Donor>
46,830
78,452
So the memory leak was kind of lame since it's just me not knowing Unity well enough and not some C# garbage collection nonsense.

Basically I'm constantly instantiating Meshes:
Unity - Scripting API:

And just assuming they are removed from memory when I stop referencing them. Instead the Unity engine keeps a reference of this class of objects and I have to call Destroy:
Unity - Scripting API:

To properly dispose of them.
 

Tuco

I got Tuco'd!
<Gold Donor>
46,830
78,452
Thanks.

Oh and because the C# GC calls the destruct component in its own thread and Unity won't let me call Destroy outside of the main render thread, I can't use a destructor to ensure that my shit is cleared when the class that holds the mesh is destructed. I need to do an explicit soft-delete of the class then dereference it.

C# really isn't to blame here, and it's probably not Unity's fault and I'm probably using the tool wrong, but this kind of behavior is what bothers me about not managing my own memory.
 

a_skeleton_03

<Banned>
29,948
29,763
Tomorrow I shall be doing my homework. Everyone prepare your lowest level skills in creating your own function and basic basic arrays in C++. I will be calling upon you!!

beacons1.jpg
 

moontayle

Golden Squire
4,302
165
Meant to post this earlier but I finally got my project into a state good enough to pass into beta testing. Now I just wait for feedback and get working on the next thing in the meantime. Three months in the making (roughly), a complete rewrite of the primary network app for our devices. Lot of learning, pushing myself to not just do a straight conversion of the old code, and a lot of trial and error. Put the last piece in today (a custom view that parses the last 50 lines of our debug log and displays to the screen) and handed it off.

Feels good man.
 

Noodleface

A Mod Real Quick
38,245
15,030
I have to take a foundations of engineering class at work that all "engineers" need to take when they are hired. It's like 100 other people - 4 days at 9 hours each day. The really shitty thing is its all talk about software layers and Hadoop clusters and hive and json.. And here I am, probably the only hardware engineer in the room feeling like I'm wasting my time. You can tell everyone else has raging boners

Oh and they're feeding us and it's worse than high-school cafeteria food.