superbrain-distributed-sdk 0.2.1 โ 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,6 +112,44 @@ The Coordinator is ONLY in the control path (allocate + free).
|
|
|
112
112
|
|
|
113
113
|
---
|
|
114
114
|
|
|
115
|
+
## ๐งน Memory Management
|
|
116
|
+
|
|
117
|
+
> **The Node.js SDK exposes the raw client layer โ `free()` is always required after `allocate()`.**
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// โ
Always do this after you are done with a pointer
|
|
121
|
+
const ptr = await client.allocate(100 * 1024 * 1024);
|
|
122
|
+
await client.write(ptr, 0, data);
|
|
123
|
+
const result = await client.read(ptr, 0, 0);
|
|
124
|
+
await client.free(ptr); // โ required โ leaks memory if skipped
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### ๐ Want Managed Memory? Use the Python SDK
|
|
128
|
+
|
|
129
|
+
The Python SDK (`pip install superbrain-sdk`) provides higher-level APIs where **free() is never needed**:
|
|
130
|
+
|
|
131
|
+
| Python API | Free needed? | What it does |
|
|
132
|
+
|------------|:------------:|--------------|
|
|
133
|
+
| `SharedContext.write("key", data)` | โ No | Key-based shared state across agents |
|
|
134
|
+
| `fabric.store_kv_cache(prefix)` | โ No | Deduped prompt cache, auto-evicted |
|
|
135
|
+
| `SuperBrainMemory` (LangChain) | โ No | Chat history in distributed RAM |
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
# Python โ no free() ever needed with high-level APIs
|
|
139
|
+
from superbrain import DistributedContextFabric
|
|
140
|
+
|
|
141
|
+
fabric = DistributedContextFabric(coordinator="localhost:50050")
|
|
142
|
+
ctx = fabric.create_context("session-42")
|
|
143
|
+
|
|
144
|
+
ctx.write("state", {"step": 10}) # written to distributed RAM
|
|
145
|
+
ctx.read("state") # read from any machine
|
|
146
|
+
# No free() โ
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
โ [Full Memory Management Guide](https://github.com/anispy211/superbrainSdk/blob/main/DOCUMENTATION.md#memory-management--when-to-free)
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
115
153
|
## ๐ Security Features
|
|
116
154
|
|
|
117
155
|
| Feature | Status |
|