Testing *correctly* is hard, and I don't understand enough of your description of your testing procedure (without making a lot of likely wrong assumptions) to say whether or not you are testing what you think you are testing, never mind whether the difference in key count is meaningful when confronted with actual system memory use. But that is beside the point.
Redis uses jemalloc to reduce the amount of memory fragmentation that Redis suffers over time. Note: *over time*. It's not necessarily about holding more keys in memory, it's about actually using less system resources in an attempt to match desired memory use (your max memory setting) with actual memory use. In Redis, the INFO command can tell you the fragmentation ratio (the amount of memory Redis is actually using divided by the amount of memory Redis *thinks* it is using), and using jemalloc will generally keep your fragmentation ratio to 1.0-1.25 in the vast majority of use-cases (this is good). But your system's built-in malloc (unless you are using an OS that defaults to tcmalloc) will have fragmentation ratios that generally increase over time (this is bad), and seeing fragmentation ratios using system malloc of 2-5 in a week or two with a modestly loaded Redis is not uncommon.
To sum up: while in the short term your tests may show that Redis using your system malloc is able to store more keys than using jemalloc, that's not the whole story. Over time, jemalloc will generally keep Redis using lower system resources than your system malloc, which you can see if you look at the output of the INFO command.
- Josiah