I found that I can help find scientific results using BOINC. As I tried, it used so much cpu or memory that my desktop hanged. Is there a way to tell Ubuntu that run BOINC but use at most, say 20% of CPU power or memory?
Yes, such options exist in the BOINC Manager and also on the project websites.
In the BOINC Manager go to "Options" -> "Computing Preferences". Under the "Computing" tab you can set how many CPUs (=Cores) will be used and to what percentage. In the "Disk and Memory" tab, you can set the limit on RAM and hard drive usage.
On the project website, you find the same settings on the home screen under "Preferences" -> "Computing preferences". Note that your computer will only apply the settings from the website once it contacts the project server the next time.
Concerning process priority
You shouldn't need to use
nice or similar tools to manually manipulate the BOINC processes on your computer. BOINC should already take care of this. For example, I see normal processes running with a "niceness" of 0, while the BOINC projects have 19, which is the lowest possible priority. If your BOINC client doesn't do this for some reason, it might be misconfigured or malfunctioning. You could seek out help and if no reason can be identified open a bug ticket for this.
The best way to avoid excessive memory usage is to select projects and applications that have low memory requirements. Many projects have a website where you find the system requirements for each of their applications. The easiest way to find them is probably to search for
<project name> system requirements in the search engine of your choice. If nothing comes up, you might want to try WU Prop. They gather statistics about CPU, memory and disk space and so on for all BOINC projects, so they are likely to have the information available. (Pro Tip: WU Prop is also a BOINC project, but doesn't require lengthy computations. If you run it on your PC, it just monitors the other BOINC processes, reports the results to the website and gives you a few extra credits.)
If this doesn't solve your problem or you want to know more, just write a comment or PM. I'm happy you want to contribute to scientific projects and it would be a shame if we couldn't figure out what settings work best for you and your computer.