// ParseAnnotationsMemory searches `s.Annotations` for the memory annotation. If
// not found searches `s` for the Windows memory section. If neither are found
// returns `def`.
//
// Note: The returned value is in `MB`.
773205
func ParseAnnotationsMemory(s *specs.Spec, annotation string, def int32) int32 {
	if m := parseAnnotationsUint64(s.Annotations, annotation, 0); m != 0 {
		return int32(m)
	}
	if s.Windows != nil &&
		s.Windows.Resources != nil &&
		s.Windows.Resources.Memory != nil &&
		s.Windows.Resources.Memory.Limit != nil &&
		*s.Windows.Resources.Memory.Limit > 0 {
		return int32(*s.Windows.Resources.Memory.Limit / 1024 / 1024)
	}
	return def
}
901813
func (m *MonitorValues) FlattenTotalMemorySizeValue() ([]FlatMonitorValue, error) {
	return m.flattenValue(func(v *MonitorValue) *float64 { return v.TotalMemorySize })
}
1174755
func (t *Thread) WriteMemory(addr uintptr, data []byte) (int, error) {
	panic(ErrNativeBackendDisabled)
}
608362
func (u *Units) GetMemory() (memory cunits.Bits) {
	return cunits.ImportInByte(float64(u.MemoryBytes))
}
88900
func GetMemory() (*Memory, error) {
	m := &Memory{}
	memoryStat, err := memVirtualMemory()
	if err == nil {
		m.Total = dataunit.Size(int64(memoryStat.Total))
	}
	return m, err
}
589018
func (c *Connect) GetMemoryStats(cellNum int, flags uint32) (*NodeMemoryStats, error) {
	var cnparams C.int

	var err C.virError
	ret := C.virNodeGetMemoryStatsWrapper(c.ptr, C.int(cellNum), nil, &cnparams, 0, &err)
	if ret == -1 {
		return nil, makeError(&err)
	}

	params := make([]C.virNodeMemoryStats, cnparams)
	ret = C.virNodeGetMemoryStatsWrapper(c.ptr, C.int(cellNum), (*C.virNodeMemoryStats)(unsafe.Pointer(&params[0])), &cnparams, C.uint(flags), &err)
	if ret == -1 {
		return nil, makeError(&err)
	}

	stats := &NodeMemoryStats{}
	for i := 0; i < int(cnparams); i++ {
		param := params[i]
		field := C.GoString((*C.char)(unsafe.Pointer(&param.field)))
		switch field {
		case C.VIR_NODE_MEMORY_STATS_TOTAL:
			stats.TotalSet = true
			stats.Total = uint64(param.value)
		case C.VIR_NODE_MEMORY_STATS_FREE:
			stats.FreeSet = true
			stats.Free = uint64(param.value)
		case C.VIR_NODE_MEMORY_STATS_BUFFERS:
			stats.BuffersSet = true
			stats.Buffers = uint64(param.value)
		case C.VIR_NODE_MEMORY_STATS_CACHED:
			stats.CachedSet = true
			stats.Cached = uint64(param.value)
		}
	}

	return stats, nil
}
603427
func (_m *API) SetHostMemory(_a0 api.HostUpdateConfig) error {
	ret := _m.Called(_a0)

	var r0 error
	if rf, ok := ret.Get(0).(func(api.HostUpdateConfig) error); ok {
		r0 = rf(_a0)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
719877
func (c *Calcium) doReallocNodesMemory(ctx context.Context, nodeContainersInfo nodeContainers, memory int64) error {
	// 只 check 增量情况下是否满足所需
	for node, containers := range nodeContainersInfo {
		if cap := int(node.MemCap / memory); cap < len(containers) {
			return types.NewDetailedErr(types.ErrInsufficientRes, node.Name)
		}
	}
	return nil
}
271497
func ReadAnnotations(bkt *bolt.Bucket) (map[string]string, error) {
	return readMap(bkt, bucketKeyAnnotations)
}
364200
func (p *Profile) ParseMemoryMapFromScanner(s *bufio.Scanner) error {
	mapping, err := parseProcMapsFromScanner(s)
	if err != nil {
		return err
	}
	p.Mapping = append(p.Mapping, mapping...)
	p.massageMappings()
	p.remapLocationIDs()
	p.remapFunctionIDs()
	p.remapMappingIDs()
	return nil
}
37634
func (conn *gdbConn) readMemory(data []byte, addr uintptr) error {
	size := len(data)
	data = data[:0]

	for size > 0 {
		conn.outbuf.Reset()

		// gdbserver will crash if we ask too many bytes... not return an error, actually crash
		sz := size
		if dataSize := (conn.packetSize - 4) / 2; sz > dataSize {
			sz = dataSize
		}
		size = size - sz

		fmt.Fprintf(&conn.outbuf, "$m%x,%x", addr+uintptr(len(data)), sz)
		resp, err := conn.exec(conn.outbuf.Bytes(), "memory read")
		if err != nil {
			return err
		}

		for i := 0; i < len(resp); i += 2 {
			n, _ := strconv.ParseUint(string(resp[i:i+2]), 16, 8)
			data = append(data, uint8(n))
		}
	}
	return nil
}
96865
func parseAdditionalSections(l string, b *bytes.Buffer, p *Profile) (err error) {
	for {
		if sectionTrigger(l) == memoryMapSection {
			break
		}
		// Ignore any unrecognized sections.
		if l, err := b.ReadString('\n'); err != nil {
			if err != io.EOF {
				return err
			}
			if l == "" {
				break
			}
		}
	}
	return p.ParseMemoryMap(b)
}
1060219
func (m *MemDB) ApproximateMemoryUsage() int {
	m.mutex.RLock()
	defer m.mutex.RUnlock()
	return len(m.kvData)
}
1079244
func parseUserAnnotations(flagUserAnnotations *kvMap) types.UserAnnotations {
	if flagUserAnnotations.IsEmpty() {
		return nil
	}
	userAnnotations := make(types.UserAnnotations)
	for k, v := range flagUserAnnotations.mapping {
		userAnnotations[k] = v
	}
	return userAnnotations
}
252832
func ZeroMemory(ctx context, name string, offset int, size uint, reg *register) string {
	chunk := uint(1)
	if size%8 == 0 {
		chunk = 8
	} else if size%4 == 0 {

		chunk = 4
	} else if size%2 == 0 {

		chunk = 2
	} else {

		chunk = 1
	}
	asm := ""
	if size/chunk == 0 {
		return asm
	}
	datatype := OpDataType{OP_DATA, InstrData{signed: false, size: chunk}, XMM_INVALID}
	mov := GetInstr(I_MOV, datatype)
	for i := uint(0); i < size/chunk; i++ {
		ioffset := int(i*chunk) + offset
		asm += instrImmMem(ctx, mov, 0, reg, name, ioffset)
	}
	return asm
}
992090
func (api *ServerAPI) SortByMemory(reverse bool) *ServerAPI {
	api.sortBy("ServerPlan.MemoryMB", reverse)
	return api
}
232594
func (t *Thread) WriteMemory(addr uintptr, data []byte) (written int, err error) {
	return t.p.conn.writeMemory(addr, data)
}