csharp icon indicating copy to clipboard operation
csharp copied to clipboard

Implement new Concept Exercise: memory-allocation

Open ErikSchierboom opened this issue 4 years ago • 5 comments

This issue describes how to implement the memory-allocation concept exercise for the C# track.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Please also watch the following video:

Goal

The goal of this exercise is to teach the student the Concept of Memory Allocation in C#.

Learning objectives

  • Know what the stack and heap are.
  • Know what the garbage collector is.
  • Know how the stack and heap are different.
  • Know what the large object heap is.
  • Know what reference and value types are.
  • Know how reference and value types relate to the stack and heap.

Out of scope

  • Memory locality.
  • Memory pooling.
  • Span<T> and Memory<T>
  • stackalloc
  • unsafe code.
  • fixed statements.
  • Defensive copies and readonly semantics.
  • Discussion of profiling tools (referring to them is fine).

Concepts

This Concepts Exercise's Concepts are:

  • memory-allocation: know what the stack and heap are; know what the garbage collector is; know how the stack and heap are different; know what the large object heap is; know what reference and value types are; know how reference and value types relate to the stack and heap.

Any data types used in this exercise (e.g. strings) should also be added as prerequisites.

Prequisites

This Concept Exercise's prerequisites Concepts are:

  • classes: know how to define and work with classes.
  • structs: know how to define and work with structs.

Resources to refer to

Hints

After

Representer

This exercise does not require any specific representation logic to be added to the representer.

Analyzer

This exercise does not require any specific analyzer logic to be added to the analyzer.

Implementing

To implement this exercise, please follow these instructions.

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue.

ErikSchierboom avatar Mar 26 '20 14:03 ErikSchierboom

Should we consider closing this issue and combining the concept with structs? Exposure to the subtleties of heap vs. stack, large object heap, garbage collection might fit more easily in structs' after.md.

mikedamay avatar Jun 08 '20 13:06 mikedamay

This is a tough call I feel. The reason why I had it as a separate exercise is because I think there is quite a bit of information here. It might be that the after.md of the structs exercise could be a bit dense. Maybe we could leave it open for now but still explore if we could add this information in the structs exercise's after.md file.

ErikSchierboom avatar Jun 09 '20 08:06 ErikSchierboom

Sounds good. Part of my reasoning was the difficulties of setting puzzles. It's also related to a point I was trying to make under Exercism's Ambition here.

mikedamay avatar Jun 09 '20 08:06 mikedamay

Yes, I read that! It is an excellent point.

ErikSchierboom avatar Jun 09 '20 09:06 ErikSchierboom

  • Contrast C# developers' attitude to out-of-memory conditions with those of lower level languages like C.

mikedamay avatar Jun 12 '20 08:06 mikedamay