I'm working on a nearly completed paper in CS. It deals with a memory module design, which, apart from being a novel idea, turned out to be of potentially commercial value. Now I was thinking of patenting it, of course, I doubt I will be able to make its commercial development a priority of mine until at least I finish my PhD (relatively soon) and find some "solid ground" in academia (I have some job offers, but can't specify any amount of time). However, I am under the impression that this should not prevent me from protecting my work. As I am quite inexperienced with it, I must also ask if I'm having the right conception and approach to patenting here? What is the procedure of patenting an idea that is to be published in a journal? Are there any consequences?
I was recently speaking with a colleague of mine who had done a lot of work in the IP area. The comment I received was that it took a lot of time from initial idea to the awarding of a patent—typically about three years and potentially lots of money (thousands of dollars or euros, depending on the filing location).
Depending on your local laws, you may be able to use your manuscript as part of the provisional patent application (an initial filing to the relevant patent office saying "we're going to file a real application soon"). However, as EnergyNumbers has suggested in a comment—you must contact someone with knowledge of local patent laws, as the rules vary greatly between countries. If your university has such an office (check with their grants and funding office for suggestions about whom you should talk to), this will save you the expense of hiring a patent attorney.
If what you have is potentially patentable do not publish any critical element before filing the patent application or you risk losing eligibility due to existence of prior art (even if it is yours!).
Be aware that your university may claim ownership of the IP since it concerns ideas that you got in the context of a project while they were paying you (my university would claim partial ownership). This need not be a problem, as this also means they get to pay the piper. This is not necessarily an issue since, if your name is on the patent, you are entitled to a slice of the cake.
You should really talk to patent experts. Your university probably has them. Most universities have a dedicated tech transfer office (TTO) which handles patents, spin-offs and industrial collaboration. They have the expertise to guide you in such endeavours.