Commit f199e2d
authored
feat: Graphql client memory optimization (#325)
## Summary
Do not produce byte array multiple times and close connection
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Avoids repeated byte-array allocations, uses fixed-length streaming
with explicit Content-Length, and always disconnects the HTTP
connection.
>
> - **Networking (`GraphQLClient.kt`)**:
> - Optimize request construction and streaming:
> - Precompute `requestBytes` (UTF-8) once; use for `Content-Length`,
`setFixedLengthStreamingMode`, and output stream writes.
> - Remove redundant writes/flushes and avoid multiple `toByteArray()`
calls.
> - Connection handling:
> - Use local `connectionLocal` with a `finally` block to `disconnect()`
the `HttpURLConnection`.
> - Minor cleanup:
> - Remove unused `Dispatchers` import.
> - Consistent use of `connectionLocal` for response/error streams.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
298a739. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 72f2592 commit f199e2d
File tree
1 file changed
+13
-10
lines changed- sdk/@launchdarkly/observability-android/lib/src/main/kotlin/com/launchdarkly/observability/network
1 file changed
+13
-10
lines changedLines changed: 13 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
| 86 | + | |
86 | 87 | | |
87 | | - | |
| 88 | + | |
88 | 89 | | |
| 90 | + | |
89 | 91 | | |
90 | | - | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 105 | + | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | | - | |
| 110 | + | |
110 | 111 | | |
111 | | - | |
| 112 | + | |
112 | 113 | | |
113 | | - | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
0 commit comments