In this work, two hyperbranched copolyimides (O-coPI and F-coPI) were synthesized which the diamine donors in the linear segment contain different substituents. To investigate the effects of substituents in donors on their memory behavior, the corresponding linear polyimides (F-LPI and O-LPI) were also discussed. The devices based on hyperbranched copolyimides exhibited non-volatile write once read many times memory (WORM) behavior, while the devices based on linear polyimides exhibited volatile memory dynamic random-access memory (DRAM) behavior. Polyimides (O-coPI and O-LPI) prepared with methoxy-substituted diamine donors have low switching voltages due to their good electron-donating properties. In addition, O-coPI and O-LPI also exhibit electrochromic properties. Hyperbranched copolyimide O-coPI have higher optical contrast and faster response time than that of linear polyimide O-LPI. This work provides a new direction for the development of multifunctional memory materials.