1,016 Matching Annotations
  1. Jan 2014
    1. Having made these points many times in the last few years, I've realized that the fundamental problem is in the mistaken belief that the type system has anything whatsoever to do with the storage allocation strategy. It is simply false that the choice of whether to use the stack or the heap has anything fundamentally to do with the type of the thing being stored. The truth is: the choice of allocation mechanism has to do only with the known required lifetime of the storage.

      The type system has nothing to do with the storage allocation strategy; the choice of allocation mechanism has to do only with the known required lifetime of the storage.

    1. Now compare this to the stack. The stack is like the heap in that it is a big block of memory with a “high water mark”. But what makes it a “stack” is that the memory on the bottom of the stack always lives longer than the memory on the top of the stack; the stack is strictly ordered. The objects that are going to die first are on the top, the objects that are going to die last are on the bottom. And with that guarantee, we know that the stack will never have holes, and therefore will not need compacting. We know that the stack memory will always be “freed” from the top, and therefore do not need a free list. We know that anything low-down on the stack is guaranteed alive, and so we do not need to mark or sweep.
    2. When a garbage collection is performed there are three phases: mark, sweep and compact. In the “mark” phase, we assume that everything in the heap is “dead”. The CLR knows what objects were “guaranteed alive” when the collection started, so those guys are marked as alive. Everything they refer to is marked as alive, and so on, until the transitive closure of live objects are all marked. In the “sweep” phase, all the dead objects are turned into holes. In the “compact” phase, the block is reorganized so that it is one contiguous block of live memory, free of holes.
    3. If we’re in that situation when new memory is allocated then the “high water mark” is bumped up, eating up some of the previously “free” portion of the block. The newly-reserved memory is then usable for the reference type instance that has just been allocated. That is extremely cheap; just a single pointer move, plus zeroing out the newly reserved memory if necessary.
    4. The idea is that there is a large block of memory reserved for instances of reference types. This block of memory can have “holes” – some of the memory is associated with “live” objects, and some of the memory is free for use by newly created objects. Ideally though we want to have all the allocated memory bunched together and a large section of “free” memory at the top.
    1. I blogged a while back about how “references” are often described as “addresses” when describing the semantics of the C# memory model. Though that’s arguably correct, it’s also arguably an implementation detail rather than an important eternal truth. Another memory-model implementation detail I often see presented as a fact is “value types are allocated on the stack”. I often see it because of course, that’s what our documentation says.
  2. Nov 2013
  3. Oct 2013
    1. Better than either of these, however, is the man who, when he wishes, can repeat the words, and at the same time correctly apprehends their meaning.

      This line is comparable to Quintilian's high regard for improvisation. Augustine seems to go along the same lines arguing that better than just memory is memory with understanding. And best of all is being able to employ all of that whenever one wishes (improvisation).

    1. Memory (as I shall show in its proper place) is most necessary to an orator and is eminently strengthened and nourished by exercise; and, at the age of which we are now speaking, and which cannot, as yet, produce anything of itself, it is almost the only faculty that can be improved by the aid of teachers.

      Memory is actually very bad. Don't put your chips into this idea. Elizabeth Loftus is a good place to start if you disagree.

    2. The remembrance of such admonitions will attend him to old age and will be of use even for the formation of his character. It is possible for him, also, to learn the sayings of eminent men, and select passages, chiefly from the poets (for the reading of poets is more pleasing to the young), in his play-time. Memory (as I shall show in its proper place) is most necessary to an orator and is eminently strengthened and nourished by exercise; and, at the age of which we are now speaking, and which cannot, as yet, produce anything of itself, it is almost the only faculty that can be improved by the aid of teachers.
    3. Memory (as I shall show in its proper place) is most necessary to an orator and is eminently strengthened and nourished by exercise; and, at the age of which we are now speaking, and which cannot, as yet, produce anything of itself, it is almost the only faculty that can be improved by the aid of teachers.
  4. Sep 2013
    1. hence it is not now easy to remember the past or consider the present or foretell the future; so that most people on most subjects furnish themselves with opinion as advisor to the soul.

      Opinion vs. memory, as if memory were absolute, infallible, objective.

    2. For if all people possessed memory concerning all things past, and awareness of all things present, and foreknowledge of all things to come

      Another instance where memory is valorized as something having great worth if not power. It will be interesting to keep an eye on this as our readings unfold.