是否delete()立即释放内存或运行时。是否需要GC()释放它?

I have a map

myMap := map[string]string
myMap['hello'] = 'world'
myMap['foo'] = 'bar'

When I delete an element from myMap like,

delete(myMap['hello'])

Does it instantly frees up memory or does it frees memory after garbage collector is run.
If it frees up memory after garbage collector is run, Does running runtime.GC() will clean up the memory instantly.

Also is runtime.GC() resource hungry ? or Its okay to run runtime.GC() after every delete() function

Update 2:
Forget what my program does (basically update 1)
Check this link http://play.golang.org/p/Wb8-4qWyf4
There is a subroutine to add to a Map every 10 Microsecond
There is a subroutine to delete from map every 1 Microsecond (10 times faster that adding)
Run this program in your local machine, you will find that its keeps on occupying more and
more RAM slowly. (Slowly because I added a sleep time, otherwise computer will hang)

Update 1
My program fetches 5000 rows of data from database every minute and stores it in a map called datastore.
There are 100 subroutines running which processes each rows from datastore. It takes much time to process one row (less than a second)
If data is successfully processed it is deleted "delete()" from datastore, but within next minute next 5000 is fetched and added to datastore.
I am keeping maximum of 20,000 rows in datastore. Which is not much (200 MB at max)
After processing millions of rows, application start taking 100% of RAM and gets Killed by kernal at the end. It should not happen if delete() was clearing the memory instantly.

You are executing your deleter only once. In addition, map access is not concurrent-safe so you need to add Mutex around your code.

Here is a fix, that will not grow with time: http://play.golang.org/p/GWQ2hJiySP

package main

import (
    "fmt"
    "sync"
    "time"
)

var datastore = make(map[int64]string)

var m sync.Mutex

func adder() {
    var count int64 = 0
    for {
        m.Lock()
        datastore[count] = "kjnbhjsdhgvsaghbsdbasjsabjhsabasbdjashdbashdbjasbdhasbdjbdjbdjhabjds"
        m.Unlock()
        count++
        time.Sleep(10 * time.Microsecond)

    }
}

func deleter() {
    for {
        m.Lock()
        for key, _ := range datastore {
            delete(datastore, key)
            time.Sleep(1 * time.Microsecond)
        }
        m.Unlock()
    }
}

func main() {
    // Start adding stuff to datastore (with MORE sleep time = 10 Microsecond)
    go adder()

    // Wait for some time
    time.Sleep(1 * time.Second)

    // Start deleting stuff from datastore (With LESS sleep time = 1 Microsecond)
    go deleter()

    time.Sleep(1 * time.Hour)
    fmt.Println("Done")
}

I have put the lock in the deleter around the whole loop. It should be only necessary around the delete, however, you should not delete entries that way, with a range, because modifying the map can change the order of the iteration, so this structure should not be used in a real-life program.