memory

In Erlang, processes share no memory and interact only by sending messages alvin June 18, 2017 - 11:28am

“In Erlang, processes share no memory and can interact with each other only by sending messages. This is exactly how objects in the real world behave.”

“I remember when I was three years old”

“Even when I was just three years old, I could recall many previous lives. But to many people this sort of thinking isn’t acceptable, so now when I’m asked what I can remember, I just say ‘I remember when I was three years old.’”

~ a monk

Android flashcards

One thing I learned about ten years ago is that when I need to memorize things, flashcards work really well for me. More recently, because I often bounce between many technologies, I have been making flashcards as a way of bringing me back up to speed after I’ve been away from a technology for a while.

The image shows one example of this, where I created a stack of flashcards to help me remember/relearn Android, which I haven’t used in several months. In this case I also have my Android cheat sheet to fall back on, but even then I still like using the flashcards. I think the theory is that rather than reading something passively, flashcards force you to try to recall something, and that’s a much more active way of using your brain and memory.

I wonder what else I did

A strange thing about the illness I’ve gone through is that I don’t have any memory of certain events.

For example — from what I can gather — during my worst time(s) I wrote this Collection of ScalaTest BDD examples using FunSpec tutorial, but I have no memory of writing it. I know that I wrote it because (a) it’s my writing style and (b) it’s on my website, but other than that, I have no recall of it. None. Zilch.

For a little while that bothered me, but now I look at it as something that’s interesting. I think it’s weird/amazing that I could write a tutorial and have no memory of writing it (or the process of researching it), but I guess that’s how the brain can work when things are screwed up. During the same time I also wrote this note to “buy some december at the grocery store,” so I know my brain was definitely going out to lunch at times.

I can see how this can be frustrating for people with chronic memory problems, but at the moment I look at it more as a mystery, like, “Huh, well, I wonder what else I did during that time?”

Getting started with the Scala REPL (command-line shell)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.1, “How to get started with the Scala REPL.”

Back to top

Problem

You want to get started using the Scala REPL, including understanding some of its basic features, such as tab completion, starting the REPL with different options, and dealing with errors.

Back to top

Solution

To start the Scala REPL, type scala at your operating system command line:

Table of Contents

  1. Problem
  2. Solution
Back to top

A Java method to log Android memory use

As a quick note today, here’s a little Java method that I use to log Android memory use (RAM use) from an Activity or Fragment:

private void logMemoryInfo(Context context, String TAG) {
   ActivityManager activityManager = (ActivityManager) context.getSystemService(getActivity().ACTIVITY_SERVICE);
   int memoryClass = activityManager.getMemoryClass();
   ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
   activityManager.getMemoryInfo(memoryInfo);

   Log.i(TAG, "\n------------ RAM -------------");
   Log.i(TAG, "mem class: " + memoryClass);
   Log.i(TAG, "mem avail: " + memoryInfo.availMem);
   Log.i(TAG, "low mem:   " + memoryInfo.lowMemory);
   Log.i(TAG, "threshold: " + memoryInfo.threshold);

   long mb = 1024*1024;
   Runtime runtime = Runtime.getRuntime();
   Log.i(TAG, "Used Memory:  " + (runtime.totalMemory() - runtime.freeMemory()) / mb);
   Log.i(TAG, "Free Memory:  " + runtime.freeMemory()  / mb);
   Log.i(TAG, "Total Memory: " + runtime.totalMemory() / mb);
   Log.i(TAG, "Max Memory:   " + runtime.maxMemory()   / mb);
}