Data structure in C-Sharp Software Development Notes


  1. In this article, I will keep notes about different #data #structures and why I should use them instead of others
  2. #Arrays in C-Sharp are #allocated on the Heap, the Heap is faster than the Stack which is why you see Integers allocated on the Heap.

    - Bigger Objects you instantiate with a "new" keyword are allocated on the Stack. The data allocated on the #Stack of #Memory can be Read Intensive and can initiate #Garbage Collection (GC) that pauses/halts the  Main #Thread the application is running on.


    Question: Can I avoid the GC by casting Lists of Objects into Arrays, since Arrays can be allocated on the Heap?


    Login to See the Rest of the Answer

    Answer:  Keep in mind when you cast the List of objects into an Array, in case you think to make execution fast or avoid chances to initiate the GC, this might even hurt your application more.
    When you cast an object into another, the Compiler is basically #boxing and #unboxing types of objects, this makes the compiler allocate even more by creating temporary space in #memory to store the boxed values and unboxed values. When evaluating, think about what you want to optimize for, do you want to optimize for Space #Complexity or Speed Complexity? then decide from there.






    References
    1. https://stackoverflow.com/questions/1113819/

This is another test

Edited Version 2

Test

#GC
Algorithms
published
v.0.01




© 2024 - ErnesTech - Privacy
E-Commerce Return Policy