No matter how many resources you have, it is never enough.
Any cool program always requires more memory than you have.
When you finally buy enough memory, you will not have enough disk space.
Sharing long urls by email or on social media sites is never a good idea, this is why most people are using urls shorteners such as biy.ly or Tinyurl.
This function takes a single parameter, an url, and will return a short url using the Tinyurl service.
function getTinyUrl($url)
{ return file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
}
Sample:
$my_url = getTinyUrl('http://www.whatever.you.want');
echo 'Short url: '.$my_url;
Sample usage within WordPress:
getTinyUrl(get_permalink($post->ID));