Emurgo / cardano-serialization-lib

This is a library, written in Rust, for serialization & deserialization of data structures used in Cardano's Haskell implementation of Alonzo along with useful utility functions.
Other
230 stars 124 forks source link

Transaction.from_bytes() works for few times before breaking. #629

Closed kushalpokharel closed 1 year ago

kushalpokharel commented 1 year ago

Problem I am using serialization-lib-asmjs for my website where I try to parse a Transaction from bytes. It works correctly for few times after which, it throws a decoding error. image This is the code that leads to this situation image I am using v11.4.0

Reproduction The problem can be reproduced by cloning and running this repository: https://github.com/kushalpokharel/cardano-serialization-lib-test

lisicky commented 1 year ago

Hi @kushalpokharel ! CSL doesn't have an automatically memory management. Your code probably reached a memory limit. Call free(); on your deserialized transaction and on every CSL object after you finish work with them.

kushalpokharel commented 1 year ago

Thank you for the reply, it doesn't crash if I call free() after logging it.

I tried experimenting with different sizes of transactions without calling free()

This means that in my app, I can't hold more than 4 transactions at a time when transactions are large.

Is there any way to increase the limit?

When I am developing a library using Cardano-serialization-lib, How do I handle this limitation?

lisicky commented 1 year ago

@kushalpokharel I would suggest to use "browser" version of the CSL if it possible to you. The "browser" version leverages wasm. This package will help you to integrate wasm into Vue project https://www.npmjs.com/package/vite-plugin-wasm