trick/docs/documentation/web/http-alloc-api.md

92 lines
3.5 KiB
Markdown
Raw Normal View History

| [Home](/trick) → [Documentation Home](../Documentation-Home) → [Web Server](Webserver) → [APIs](WebServerAPIs) → HTTP Alloc API |
|------------------------------------------------------------------|
2019-11-19 20:21:07 +00:00
# HTTP-API: alloc_info
```http://localhost:8888/api/http/alloc_info```
2019-11-19 20:21:07 +00:00
## Purpose
Request a JSON encoded sub-list of allocation descriptors from the Memory Managers alloc_info list.
2019-11-19 20:21:07 +00:00
## Query String Parameters
| Parameter|Default|Description |
|-------------|----|----------------------------------|
| ```start``` | 0 | starting index of the sub-list. |
| ```count``` | 20 | number of allocation descriptors.|
2019-11-19 20:21:07 +00:00
### EXAMPLE:
```http://localhost:8888/api/http/alloc_info?start=20&count=2```
## Query Response
Returns a JSON object containing four name-value pairs:
### JSON Response Object
2019-11-19 20:21:07 +00:00
| Name | Value Description |
|-------------------|-----------------------------------------|
| ```alloc_total``` | Total number allocations in the Memory Managers alloc_info list. |
2019-11-19 20:21:07 +00:00
| ```chunk_size``` | Number of allocation description objects in ```alloc_list```. |
| ```chunk_start``` | The Memory Manager alloc_info index of the first ```alloc_list``` element below|
| ```alloc_list``` | Array of JSON Allocation Description objects (described below). |
### JSON Allocation Description Object
| Name | Value Description |
|---------------|---------------------------------------------------------------------------------|
| ```name``` | Name of the allocation. May be ```Null``` |
2019-11-19 20:21:07 +00:00
| ```start``` | Starting address of the allocation. |
| ```end``` | Ending address of the allocation. |
| ```num``` | |
| ```size``` | Size of the allocation in bytes. |
| ```type``` | Type descriptor of the allocation. |
| ```stcl``` | Storage class of the allocation. Either ```TRICK_EXTERN``` or ```TRICK_LOCAL```.|
| ```language```| Language. Either : ```Language_C``` or ```Language_CPP```. |
| ```index``` | Array dimension sizes of the allocation (if it represents an array). |
## Example:
In ```SIM_cannon_numeric``` (one of Trick's example sims) the following query resulted in the following JSON.
#### Query
```http://localhost:8888/api/http/alloc_info?start=20&count=2```
#### Response
```json
{ "alloc_total":43,
"chunk_size":2,
"chunk_start":20,
"alloc_list":[
{ "name":"dyn",
"start":"0x101aa9900",
"end":"0x101aa9b27",
"num":"1",
"size":"552",
"type":"CannonSimObject",
"stcl":"TRICK_EXTERN",
"language":"Language_CPP",
"index": []
}
,
{ "name":"web",
"start":"0x101aa9610",
"end":"0x101aa98ff",
"num":"1",
"size":"752",
"type":"WebServerSimObject",
"stcl":"TRICK_EXTERN",
"language":"Language_CPP",
"index": []
}
]
}
```
Continue to [WS Variable Server API](ws-variable-server-api)