Files
z-docs/docs/admin-apis/cleanup-api.md

54 lines
1012 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebar_position: 2
title: 清理内存接口
description: ZHub 服务内存清理接口
---
# 清理内存接口
## 接口说明
- **路径**: `GET /_/cleanup`
- **功能**: 清理可回收的内存资源
- **用途**: 释放无用的主题和消息,优化内存使用
## 清理条件
清理满足以下条件的主题:
- `subsize = 0` - 没有订阅者
- `mcount = offset` - 没有待消费的消息
## 使用示例
```bash
# 手动触发内存清理
curl http://127.0.0.1:711/_/cleanup
```
## 返回信息
接口返回清理操作的结果:
- **成功**: 返回 `"+OK"`
- **失败**: 返回错误信息
**响应示例**
```json
"+OK"
```
## 清理机制
**手动清理**:通过调用此接口立即触发清理操作
- 清理所有符合条件的主题
- 释放相关内存资源
## 应用场景
1. **内存优化**: 当发现内存占用过高时手动清理
2. **性能调优**: 在性能测试后清理测试数据
3. **资源回收**: 清理不再使用的主题和消息