// mem per-conn store
509169
func (c *connection) SetValue(key string, value interface{}) {
	c.values.Set(key, value)
}
178307
func (pool *SyncPool) Free(mem []byte) {
	if size := cap(mem); size <= pool.maxSize {
		for i := 0; i < len(pool.classesSize); i++ {
			if pool.classesSize[i] >= size {
				pool.classes[i].Put(&mem)
				return
			}
		}
	}
}
1122568
func OnConnect(memif *libmemif.Memif) (err error) {
	details, err := memif.GetDetails()
	if err != nil {
		fmt.Printf("libmemif.GetDetails() error: %v\n", err)
	}
	fmt.Printf("memif %s has been connected: %+v\n", memif.IfName, details)

	stopCh = make(chan struct{})
	// Start a separate go routine for each RX queue.
	// (memif queue is a unit of parallelism for Rx/Tx).
	// Beware: the number of queues created may be lower than what was requested
	// in MemifConfiguration (the master makes the final decision).
	// Use Memif.GetDetails to get the number of queues.
	var i uint8
	for i = 0; i < uint8(len(details.RxQueues)); i++ {
		wg.Add(1)
		go IcmpResponder(memif, i)
	}
	return nil
}
1099367
func main() {
	data := map[string]int{}

	for i := 0; i < 100; i++ {
		err := retro.DoWithRetry(func() error {
			return storeInt(data, i)
		})
		if err != nil {
			fmt.Printf("FATAL: Failed to store %d: %s\n", i, err.Error())
			os.Exit(1)
		}
	}

}
239099
func (memory *InMemory) Store(m *data.Message) (string, error) {
	memory.mu.Lock()
	defer memory.mu.Unlock()
	memory.Messages = append(memory.Messages, m)
	memory.MessageIDIndex[string(m.ID)] = len(memory.Messages) - 1
	return string(m.ID), nil
}
30266
func NewMemStore(sid string) *MemStore {
	return &MemStore{
		sid:        sid,
		data:       make(map[interface{}]interface{}),
		lastAccess: time.Now(),
	}
}
687476
func (mem DevicePtr) MemSize() uintptr {
	size, _, err := mem.AddressRange()
	if err != nil {
		log.Printf("MEMSIZE ERR %v", err)
	}
	return uintptr(size)
}
1046525
func NewKeyMemoryStore(p notary.PassRetriever) *GenericKeyStore {
	memStore := store.NewMemoryStore(nil)
	return NewGenericKeyStore(memStore, p)
}
1278854
func (rs *copResponse) MemSize() int64 {
	if rs.respSize != 0 {
		return rs.respSize
	}

	// ignore rs.err
	rs.respSize += int64(cap(rs.startKey))
	rs.respSize += int64(sizeofExecDetails)
	if rs.CommitDetail != nil {
		rs.respSize += int64(sizeofCommitDetails)
	}
	if rs.pbResp != nil {
		// Using a approximate size since it's hard to get a accurate value.
		rs.respSize += int64(rs.pbResp.Size())
	}
	return rs.respSize
}
888631
func (ctx *BatchedContext) MemAlloc(bytesize int64) (retVal DevicePtr, err error) {
	fn := &fnargs{
		fn:   C.fn_mallocD,
		size: C.size_t(bytesize),
	}
	c := call{fn, true}
	return ctx.enqueue(c)
}
859052
func (db *DB) getMems() (e, f *memDB) {
	db.memMu.RLock()
	defer db.memMu.RUnlock()
	if db.mem != nil {
		db.mem.incref()
	} else if !db.isClosed() {
		panic("nil effective mem")
	}
	if db.frozenMem != nil {
		db.frozenMem.incref()
	}
	return db.mem, db.frozenMem
}
345299
func (*HandlerT) MemStats() *runtime.MemStats {
	s := new(runtime.MemStats)
	runtime.ReadMemStats(s)
	return s
}
1331674
func NewMem() Data {
	return &memData{l: &sync.RWMutex{}, strings: make(map[string]string), ints: make(map[string]int)}
}
823077
func (p *MemProvider) Read(sid string) (_ RawStore, err error) {
	p.lock.RLock()
	e, ok := p.data[sid]
	p.lock.RUnlock()

	if ok {
		if err = p.update(sid); err != nil {
			return nil, err
		}
		return e.Value.(*MemStore), nil
	}

	// Create a new session.
	p.lock.Lock()
	defer p.lock.Unlock()

	s := NewMemStore(sid)
	p.data[sid] = p.list.PushBack(s)
	return s, nil
}
424182
func (t *cacheTracker) SubMemBytes(bytes uint64) {
	atomic.AddUint64(&t.memSizeBytes, ^(bytes - 1))

	labels := t.labels
	t.metrics.MemSize.With(labels).Sub(float64(bytes))
}
711250
func WithDummyInMemory(ctx context.Context) (context.Context, *monitor.Fake) {
	m := &monitor.Fake{}
	return WithState(ctx, &State{
		store:                        store.NewInMemory(&target.Task{}),
		monitor:                      m,
		invokeGlobalCallbacksOnFlush: true,
	}), m
}
1173563
func (r *OffsetReaderAt) ReadMemory(buf []byte, addr uintptr) (n int, err error) {
	return r.reader.ReadAt(buf, int64(addr-r.offset))
}