Changing Pagefile (Virtual Memory) settings in Windows 10

The Pagefile is a file used by Windows that is kept on the hard-drive. Pagefile is also known as Virtual Memory. It acts as an additional cache for things that might be kept in RAM, but stored this way because either RAM is too full or the data might be needed to made persistent.

If you frequently run out of RAM, increasing the pagefile will help to keep your programs running properly could stop crashes caused by low memory.

Some things you need to know

  • Data stored in the in the Pagefile is not optimal as hard-drives are much slower to access then in physical RAM.
  • Important: Pagefile/Virtual Memory is not recomended on SSDs as the file can be written to and read from fairly frequently and can cause premature wear on the drive. If you’re not worried about wear, you may still set a page file.
    You may also move the pagefile to a mechanical drive or set the file to a static amount.
    Also to note: as SSD tech matures, the agility of flash increases thus lowering potential wear.

Changing the settings

Use Cortana to search for “Advanced system settings“:

Search Cortana: advanced system settings
Search Cortana: advanced system settings

Clicking into Advanced system settings will bring up the “System Properties” view. In the “Advanced” tab, click “Settings…” under the “Performance” section:

System Properties: Advanced
System Properties: Advanced

This will bring up the “Performance Options” view. Continue to the pagefile settings by clicking “Change…” under “Virtual Memory” in the “Advanced” tab:

Performance Options: Virtual Memory
Performance Options: Virtual Memory

Lastly, you should be presented with the “Virtual Memory” view where you will be able to control your pagefile settings:

Virtual Memory view
Virtual Memory view

You can set a static size, move the pagefile to another drive or simply let Windows take control of the virtual memory with dynamic allocation.

Overcoming a resource famine

This may seem as another moan about how bad my AMD FX6350 is, however it isn’t. Much. I have arrived at the point where another Virtual Machine wouldn’t only be handy, but critically important for various reasons.

My current usage is as follows:

  1. Windows 10 host – SSD1
  2. Ubuntu 16.04 guest – HDD 1 – 2 VCore / 3 (allocatable)
  3. Ubuntu 18.04 Server guest – HDD1 – 1 VCore / 3 (allocatable)

VirtualBox allows 3 out of 6 cores to be allocated to VM’s. It seems the FX6350 isn’t a “true” 6 core processor and instead sees 3 physical as 6 logical processors.

The current configuration worked well, until I decided I wanted to test my 18.04 server (hosting my web app) against some attacks via Kali. This would mean that I would need another VM as 4, to test against 3. This would mean the CPUs are being pushed to the point where they (the host and guests) would not operate correctly.

I immediately decided to throw more power at the problem as I was lacking at least a few cores to accomplish this. I had 2 solutions:

  1. Set up a spare PC to play role as 18.04 server or Kali
  2. Buy a new PC altogether with enough cores to cater for the downfalls

Problem with solution 1: Another PC will be running and I do not have another monitor/mouse/keyboard/space/power socket(s) to  accommodate for something that could be done a lot easier on a single machine

Problem with solution 2: Not sure if my Windows 8.1 license will still apply an upgrade to Windows 10. Also, the obvious monitory cost involved.

Wielding my credit card, I was very close to ordering a spanking new Ryzen 7 2700x bundle from Overclockers.co.uk for a princely sum. At that moment, I instantly thought of a lesser (cheaper) solution.

Whilst (in theory) all 3 guests where happily working with/against each-other, the host will be nothing more then a host. Doing nothing, other then sharing resources, whilst using them. Removing the Windows 10 host lead me to the penultimate conclusion.

  1. Ubuntu 18.04 host – SSD 2
  2. Ubuntu 18.04 server guest – HDD1 – 1 VCore / 3 (allocatable)
  3. Kali guest – HDD1 – 2 VCore / 3 (allocatable)

Instantly I can start to see bottlenecks here, hence the “lesser”. I could extend a guest to HDD2, If I need to.  However, I have dodged a large sum of credit whilst achieving what I wanted. (in theory at least)

It seems that for the time being, the 2013 processor popular with gamers-on-a-budget still fits its purpose (barely). Being coy about the situation, I have averted a cost and will keep me warm through winter (although dreadful in the current heatwave). Eventually, I will have to let it go but until then I await for DDR5 and future processors to add to the mounting upgrade-ability from this long dead platform.

Compile and install Python’s MOD_WSGI for Apache2 in Ubuntu 18.04

Having installed mod_wsgi a couple of times on different machines, I decided to note down the steps I took and put together a guide. There are also some solutions to some issues that you may encounter, which left me clueless for a while. If you are looking for a guide to deploying a Flask/Django project, you will have to look elsewhere (for the time being).

This is for use with python3 using Ubuntu 18.04’s shipped version. You may need to tweak this guide to point to non-standard versions of python3 that you specifically want to use.

I believe some Ubuntu versions have pre-packaged mod_wsgi installations available. However, noted in a previous blog post, apache2 may flood error logs pointing to a mismatch with either differing python3 or apache2 versions and in my view, a clean compilation ensures a tailored fit to your current system without the worry of logging and runtime errors.

Things to note:

  • I prefer to compile inside the “/opt” directory. Please amend the guide to suite your preference
  • I will refer to the current latest version of mod_wsgi (4.6.4 at time of writing). This is for illustrative purposes only, and some directory paths will be different with different versions
  • The guide is built around CLi, and assumes you are comfortable with the basics

Pre-Requisites

You will need to have installed some additional packages:

  • python3-dev  –  mainly for python3 header files for compilation
  • apache2
  • apache2-dev
  • gcc  –  *or an equivalent C compiler*

You may use apt install for all the above packages

Next, you will need to locate the latest mod_wsgi source files (found here)

Downloading

Navigate to /opt and download the latest version of mod_wsgi:

$ cd /opt
$ wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.6.4.tar.gz

Unpack the tar:

$ tar -xzf 4.6.4.tar.gz mod_wsgi-4.6.4/

Configure Make file

Change into the unpacked directory:

$ cd mod_wsgi-4.6.4/

Complete a “test” run of the configure script to so you can debug any errors:

$ ./configure

 

  • Error: “configure: error: no acceptable C compiler found in $PATH
    Solution: install a C compiler:

    $ sudo apt install gcc

 

  • Error: “Checking Apache Version.. ./configure: line 2765: apsx: command not found
    Solution: install apache2-dev

    $ sudo apt install apache2-dev

 

  • Error: “checking for python… no
    Solution: add argument to ./configure to point to python3 (global) or full path

    $ ./configure --with-python=python3

If you run configure without any errors, you’re ready to compile!

Compiling mod_wsgi

The make file is ready. Run Make:

$ make

This will now compile mod_wsgi. It should complete without error.

We finish the process by installing mod_wsgi to our apache2 installation:

$ make install

Configure Apache2

Finally, we need to configure apache2 correctly to load the mod_wsgi module. There are 2 ways we can do this:

  1. The “lazy way”:
    Add the following to the end of the apache2.conf file:
    (located: “/etc/apache2/apache2.conf“)

    LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

    Restart Apache2:

    $ sudo systemctl restart apache2

    If apache2 restarts without errors, you have successfully installed and loaded mod_wsgi!

  2. The “proper” way:
    Navigate to “/etc/apache2/mods-available“Create “mod_wsgi.conf”:

    $ sudo touch mod_wsgi.conf

     

    Add the following to” mod_wsgi.conf”:

    <IfModule mod_wsgi.c>
    </IfModule>

    For further information about the configuration options that can be included in “mod_wsgi.conf”, refer to docs : https://modwsgi.readthedocs.io/en/develop/configuration.html

    Create “mod_wsgi.load”:

    $ sudo touch mod_wsgi.load

    Add the following to “mod_wsgi.load”:

    LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

    Activate module in Apache and follow onscreen instructions:

    $ sudo a2enmod mod_wsgi

    If apache2 restarts without errors, you have successfully installed and loaded mod_wsgi!

uhex – a CLi hex editor

jsephler project - default image

A quick and easy to use CLi script to transform hex values into different data types.


Current known limitations:

  • Hex order : will only convert from Big-Endian hex orders
  • Hex to int : will only convert hex to unsigned integers

Known Issues:

  • Hex to float not yet fully working

The script is available from github :

github : uhex

Update – April 2018

I have been quiet here on the blog, however my brain has been working non-stop! I feel that I would like to post something here, but I haven’t had anything to “physically” bring to the e-world. So, heres a small update on what’s been happening over the past few months.

Algorithms

For an odd reason as of late, I have been dead set on generating prime numbers. Where this idea came from, I’m not quite sure but it has taken up a large portion of my time.

Originally starting with the bog-basic method of finding a prime number, I created a generator in Python. Now, this may seem boring and arbitrary for most, but I really enjoyed creating and testing this algorithm.
I spent a while researching about prime numbers (as I’m by no means a mathematician), and slowly started to optimize it.

It was whilst numbers greater then 1,000,000 took longer to process, I started to explore different avenues to speed this up.
I first looked into processing these numbers on different threads.  Obviously, there were a number of ways I could do this.

  1. Send a number n to it’s own thread for prime testing
  2. Split the number n in [x number of threads] ways and give each chunk to a separate thread to test. If a thread returned “not prime”, close all threads and start on next n

As you can see, it started to get complicated. Even more-so when this avenue started to dwindle when I realized a thread is just a time share of the same die, not a seperate CPU process. So I then explored the idea of multi-processing.. which would be great for option 2 above.

This became even more complicated as memory isn’t shared between the parent and child processes. I did however, build an algorithm that would split a number between X threads/processes, which works quite nicely.

Still staying with prime numbers, I was interested to see if my Python algorithm would run quicker in another language, so I re-wrote the logic in C and ran the test. It ran super quick, and I was really surprised by the performance increase!

I then explored the idea of importing my C algorithm into Python and running it, but came against some problems. Python will add bits to an int to accommodate for really large numbers, where C seems to lose interest at u_int64.
I hit a nerve when I found this; I ultimately wanted to leave it to run, just to see the biggest number I could find. Obviously, my C algorithm wouldn’t hold up to this, which was a great shame I feel.

I have for now, put this sideline to rest, until I find some more free time.

Webapps

I decided that it was time to expand the internet just a little bit more.

It had been a while since I last created a web app, infact it was my final CS50 project in Flask. I know Flask isn’t greatly maintained anymore, and therefore isn’t used for larger projects. People seem to be moving to Django more and more, so there I went.

I have a collection of calculators, references, generators etc. that I have accumulated and I really wanted to start to put in a nice big box with a bow on top. I also wanted to tie it to jsephler.co.uk somehow, allowing a central location for me and others to access from.

I also wanted to take a dive into website meta data and learn more about it.

Armed with my knowledge of Flask and trusted Bootstrap, I decided to finally take the plunge and learn Django. And boy am I not dissapointed!

Django really is fantastic, and is packed full of some really great features. After shuffling through alot of the documentation and getting my head around Models, I have a good understanding and has been a relativly smooth transition.

I will probably use Django from now on.

Im hoping that my next blog post will be a big reveal, unveiling the new site, however there’s still plenty of work to be done!