It is impossible. The RAM on the Raspberry Pi is soldered in, and can't be replaced. Even if you somehow could, the Videocore IV architecture (which powers the Raspberry Pi) does not support 4GB of RAM. (Edit: the Raspberry Pi actually doesn't even support 1GB of RAM.Oct 5, 2018