However this portion is completely useless for the rest of the game after she earns this achievement. And I need to do as many this kind of tests as the number of achievements in the game. I wonder if there is a way to deal with such problem
in the big picture, its only a problem if your code exceeds ram. you'll want to go with the implementation that gets the job done with the least amount of effort. building games is a big job. you want to work smart, not hard.
the last time i had to seriously engineer around something like that was about 1982 when i was writing my first game, a text mode D&D rpg clone on a Sperry Rand 8088 PC, dos 2.11, and MS Basic. the PC only had 64K of RAM, so you had to use overlay files (modules that paged in and out of memory automatically, with about a 1 second delay). nowadays, windows pages ram as needed, so you have lots of ram, up to the limits of physical ram + max page file size (typically 10% of hard drive? maybe less with today's huge drives).
usually its horrendously huge data structures, not code, that makes you run out of ram.
i've done games as big as 100,000+ lines of code with no problems.
my current main project is at 70,000+ lines of code, and i don't even BEGIN to think about the size of my code segment. OTOH, i HAVE declared data structures that result in "error: program too big to compile", or "data segment exceeds addressable ram", or some such thing. that's when i go for paging strategies.
dynamic allocation exceeding available ram can be an issue.
"code segment too big" almost never is these days.