If the playlist is loaded directly from a protocol like memory://, the playlist_path represents the entire playlist. In cases where we have a large playlist, this results in the entire playlist being duplicated for each item. For example, if the input size is 300 kB with 10k items, we end up using 3 GB of memory just to store the playlist_path strings.
Unified · Split
| @@ -159,9 +159,10 @@ void playlist_append_file(struct playlist *pl, const char *filename) · 158 unmodified lines | |||
| 159 | 159 | ||
| 160 | void playlist_populate_playlist_path(struct playlist *pl, const char *path) | 160 | void playlist_populate_playlist_path(struct playlist *pl, const char *path) |
| 161 | { | 161 | { |
| 162 | char *playlist_path = talloc_strdup(pl, path); | ||
| 162 | for (int n = 0; n < pl->num_entries; n++) { | 163 | for (int n = 0; n < pl->num_entries; n++) { |
| 163 | struct playlist_entry *e = pl->entries[n]; | 164 | struct playlist_entry *e = pl->entries[n]; |
| 164 | e->playlist_path = talloc_strdup(e, path); | 165 | e->playlist_path = playlist_path; |
| 165 | } | 166 | } |
| 166 | } | 167 | } |
| 167 | 168 | ||
| @@ -338,6 +339,7 @@ int64_t playlist_transfer_entries_to(struct playlist *pl, int dst_index, · 170 unmodified lines | |||
| 338 | e->id = ++pl->id_alloc; | 339 | e->id = ++pl->id_alloc; |
| 339 | pl->entries[e->pl_index] = e; | 340 | pl->entries[e->pl_index] = e; |
| 340 | talloc_steal(pl, e); | 341 | talloc_steal(pl, e); |
| 342 | talloc_steal(pl, e->playlist_path); | ||
| 341 | } | 343 | } |
| 342 | 344 | ||
| 343 | playlist_update_indexes(pl, dst_index + count, -1); | 345 | playlist_update_indexes(pl, dst_index + count, -1); |