Scala Quicksort algorithms: FP/recursive, imperative (and performance) alvin November 2, 2015 - 4:13pm

As a short “note to self,” the quickSort function in the following code is from the “Scala By Example” PDF, and it shows a Scala version of a Quicksort algorithm:

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();

   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);
How to show memory usage in a running Scala application alvin October 6, 2014 - 12:04pm

You can show used, free, total, and max memory (RAM) available in a Scala application just like you do in Java. The lines of code look like this:

Scala REPL: java.lang.OutOfMemoryError: Java heap space error alvin April 27, 2013 - 12:03pm

I just got a “java.lang.OutOfMemoryError: Java heap space error” when trying to use the Scala REPL to analyze a large XML dataset, as shown here:

Linux: How to get CPU and memory information alvin June 19, 2011 - 6:49pm

Linux FAQ: How can I find Linux processor and memory information? (Also written as, How can I find Linux CPU information?, How can I find Linux RAM information?)

To see what type of processor/CPU your computer system has, use this Linux processor command:

cat /proc/cpuinfo

As you can see, all you have to do is use the Linux cat command on a special file on your Linux system. (See below for sample processor output.)

To see your Linux memory information and memory stats use this command:

The Drupal Diaries, Day 12 alvin August 29, 2009 - 8:36pm

If you're interested in the really short story, this Drupal-based website is now hosted on a new, dedicated Linux server with much more RAM than the old server. For the longer story -- and the details of Apache tweaks and a script to automatically restart Apache when it got hung up -- read on.

Surprised by the Drupal plus LAMP memory use

I ended up being really surprised, but it turns out that Drupal and the LAMP architecture (Linux, Apache, MySQL, and PHP) take much more memory than the old Java-based blog that I had running the DevDaily site previously.