// Memory sets he amount of memory the application can consume per instance
//		memory:	the amount of MB to assign
768238
func (r *Application) Memory(memory float64) *Application {
	r.Mem = &memory

	return r
}
1202545
func (c *Chunk) MemoryUsage() (sum int64) {
	for _, col := range c.columns {
		curColMemUsage := int64(unsafe.Sizeof(*col)) + int64(cap(col.nullBitmap)) + int64(cap(col.offsets)*4) + int64(cap(col.data)) + int64(cap(col.elemBuf))
		sum += curColMemUsage
	}
	return
}
1220294
func (m *MemoryRange) ReadMemory(buf []byte, addr uintptr) (int, error) {
	if len(buf) == 0 {
		return 0, nil
	}
	if (uint64(addr) < m.Addr) || (uint64(addr)+uint64(len(buf)) > m.Addr+uint64(len(m.Data))) {
		return 0, io.EOF
	}
	copy(buf, m.Data[uint64(addr)-m.Addr:])
	return len(buf), nil
}
1173563
func (r *OffsetReaderAt) ReadMemory(buf []byte, addr uintptr) (n int, err error) {
	return r.reader.ReadAt(buf, int64(addr-r.offset))
}
593497
func (s *UpdateFunctionConfigurationInput) SetMemorySize(v int64) *UpdateFunctionConfigurationInput {
	s.MemorySize = &v
	return s
}
545516
func (mc *cache) Size() int {
	mc.mu.Lock()
	defer mc.mu.Unlock()
	return mc.size
}
158767
func (ar *allocRunner) Alloc() *structs.Allocation {
	ar.allocLock.RLock()
	defer ar.allocLock.RUnlock()
	return ar.alloc
}
418023
func (b *Bytes) Write(data []byte) (n int, err error) {
	b.bytes, n, err = b.write(data)
	return n, err
}
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
}
1147024
func (s *Container) SetMemory(v string) *Container {
	s.Memory = &v
	return s
}
1285582
func memoryStats() (*memory, error) {
	mstat := struct {
		size      uint32
		_         uint32
		totalPhys uint64
		availPhys uint64
		_         [5]uint64
	}{}

	// windows sets return value to 0 when function fails.
	mstat.size = uint32(unsafe.Sizeof(mstat))
	ret, _, err := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&mstat)))
	if ret == 0 {
		return nil, err
	}

	// memoryStats functions from other platforms return memory usage in bytes.
	return &memory{
		Usage: mstat.totalPhys - mstat.availPhys,
		Total: mstat.totalPhys,
	}, nil

}
1048604
func (memory *InMemory) Load(id string) (*data.Message, error) {
	if idx, ok := memory.MessageIDIndex[id]; ok {
		return memory.Messages[idx], nil
	}
	return nil, nil
}
275264
func (s *ContainerDefinition) SetMemory(v int64) *ContainerDefinition {
	s.Memory = &v
	return s
}
1108476
func NewMemoryCache(memoryLimit int, objectLimit int) *MemoryCache {
	return &MemoryCache{memoryLimit: memoryLimit,
		objectLimit: objectLimit,
		object:      make(map[string]Object)}
}
1091715
func (world *World) Malloc(flags uint, size uint) *Memory {
	var f C.cl_mem_flags
	switch flags {
	case ReadOnly:
		f = C.CL_MEM_READ_ONLY
	case WriteOnly:
		f = C.CL_MEM_WRITE_ONLY
	case ReadWrite:
		f = C.CL_MEM_READ_WRITE
	}
	m := C.xcl_malloc(world.cw, f, C.size_t(size))
	return &Memory{world, size, m}
}
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
}
770591
func (d *Context) Alloc(size int) unsafe.Pointer {
	return C.duk_alloc(d.duk_context, C.duk_size_t(size))
}