You set environment variables in a process and they are inherited by all the child processes. Exactly how you go about that depends on where you want it to be available. You don't have to modify any GLib configuration, though.
To set an environment variable for programs started from your shell (I'll assume Bash here), you can write:
All programs you start from this shell session after that will have the variable set.
If you want it to be set for every shell you start afterwards, add that line to
~/.profile as well. In that case it will apply to all future shells you start, but not any that are currently running.
To set it for just a single execution of a program (perhaps to debug its effects), precede the command with the variable assignment:
$ G_SLICE=always-malloc gsomething
Those are all for commands you run from the terminal.
.profile will generally work for the GUI as well, but that can be broken by system configuration. They're all per-user configuration as well.
If you want it set for every user all the time, you can (likely) add an assignment to
/etc/environment. The format is a little different there: just
KEY=VAL on separate lines, with no required quoting and none of anything else.
This is (again, likely — system-dependent) parsed by the
pam_env module. There is a per-user
~/.pam_environment file as well, which has the same effect for just the one user, but may or may not be enabled on your distribution. These both require logging out and back in for the change to take effect.
Alternatively, you can add the
export statement in
~/.xinitrc (if you use
~/.xsession (for most login managers). KDE supports a directory
~/.kde/env that can contain as many shell files as you want, which contain
export statements as above.