Memtest is a free to shareware application. This means that you can use it in the free mode without limitations, but if you want some additional features there is also the PRO version, however, you can't modify its source code.
Alternatively, there is memtest86+ which is a completely open source software with the possibility to compile it and use it for your own needs. You can check its official website for this information.