# getmemoryinfo

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://bitcoin-mainnet.g.alchemy.com/v2/{apiKey}

Returns information about memory usage, either general statistics ("stats") or heap information ("mallocinfo").


Reference: https://www.alchemy.com/docs/chains/bitcoin/bitcoin-api-endpoints/getmemoryinfo

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| mode | enum | No | Determines what kind of information is returned: - "stats" returns general statistics about memory usage. - "mallocinfo" returns an XML string describing low-level heap state.  |

## Result

**result** (object): Memory usage details.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "getmemoryinfo",
  "params": [
    "stats"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "locked": {
      "used": 352,
      "free": 65184,
      "total": 65536,
      "locked": 65536,
      "chunks_used": 1,
      "chunks_free": 1
    }
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getmemoryinfo",
  "params": [
    "stats"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({jsonrpc: '2.0', id: 1, method: 'getmemoryinfo', params: ['stats']})
};

fetch('https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getmemoryinfo",
    "params": ["stats"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getmemoryinfo\",\n  \"params\": [\n    \"stats\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getmemoryinfo\",\n  \"params\": [\n    \"stats\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getmemoryinfo\",\n  \"params\": [\n    \"stats\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: getmemoryinfo
summary: Get memory usage information
description: |
  Returns information about memory usage, either general statistics ("stats") or heap information ("mallocinfo").
params:
  - name: mode
    required: false
    description: |
      Determines what kind of information is returned: - "stats" returns general statistics about memory usage. - "mallocinfo" returns an XML string describing low-level heap state.
    schema:
      type: string
      enum:
        - stats
        - mallocinfo
result:
  name: result
  description: Memory usage details.
  schema:
    type: object
    properties:
      locked:
        type: object
        description: Information about locked memory.
        properties:
          used:
            type: integer
            description: Used memory in KB.
          free:
            type: integer
            description: Free memory in KB.
          total:
            type: integer
            description: Total memory available in KB.
          locked:
            type: integer
            description: Locked memory in KB.
          chunks_used:
            type: integer
            description: Number of used memory chunks.
          chunks_free:
            type: integer
            description: Number of free memory chunks.
examples:
  - name: getmemoryinfo stats example
    params:
      - name: mode
        value: stats
    result:
      name: result
      value:
        locked:
          used: 352
          free: 65184
          total: 65536
          locked: 65536
          chunks_used: 1
          chunks_free: 1
```
