# Motoko WASM size diagnosing tips?

**URL:** <https://forum.dfinity.org/t/motoko-wasm-size-diagnosing-tips/25268>\
**Category:** Motoko\
**Created:** [December 4, 2023, 6:59pm UTC](https://forum.dfinity.org/t/motoko-wasm-size-diagnosing-tips/25268 "2023-12-04T18:59:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gekctek](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gekctek/32/6863_2.png) [@Gekctek](https://forum.dfinity.org/u/Gekctek)\
**Post date:** [December 4, 2023, 6:59pm UTC](https://forum.dfinity.org/t/motoko-wasm-size-diagnosing-tips/25268/1 "2023-12-04T18:59:18Z")

</div>

I am trying to find the best way to diagnose why one of my Motoko wasm output files is huge

I have tried wasm2wat to see if i could manually inspect it but i get the error `002919d: error: unexpected opcode: 0xc0`, so thats not helpful

It probably is one of my dependencies, but I am having to manually go through and see if removing dependencies fixes it.

Was wondering if there were any tips for figuring out size issues besides guessing and checking

NOTE: dfx build 0.15.1 it was ~1.67MB, then after building with 0.15.2, the size is just over 2MB. So not sure whats going on with that? but it made me investigate since it was too large to deploy

---

<div class="post-metadata">

**Author:** ![Gekctek](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gekctek/32/6863_2.png) [@Gekctek](https://forum.dfinity.org/u/Gekctek)\
**Post date:** [December 4, 2023, 7:15pm UTC](https://forum.dfinity.org/t/motoko-wasm-size-diagnosing-tips/25268/2 "2023-12-04T19:15:19Z")

</div>

Hmm. Also it might be good to know how imports work

When i just have a commented out file and just have `actor {}` as code i get `126 KB` file  
With uncommented just the import statements, with no actor code, i get `330 KB` file  
With everything uncommented i get the over `2MB` file

Is this an import optimization? where if its not used it wont be included? Or would there just be something with the code itself?

This is my file that I’m trying to figure out

> <https://github.com/edjCase/daoball/blob/main/src/backend/league/LeagueActor.mo>

---

<div class="post-metadata">

**Author:** ![Gekctek](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gekctek/32/6863_2.png) [@Gekctek](https://forum.dfinity.org/u/Gekctek)\
**Post date:** [December 4, 2023, 7:35pm UTC](https://forum.dfinity.org/t/motoko-wasm-size-diagnosing-tips/25268/3 "2023-12-04T19:35:10Z")

</div>

Seems with my specific issue is that I am including multiple actor classes which end up being ~500KB in size each.  
Made a new thread for that

> [@Motoko actor class deployment options](https://forum.dfinity.org/t/motoko-actor-class-deployment-options/25271):
>
> I have an issue where I have a few actor classes that I want to deploy from my main canister but I am running into an issue where each actor class takes about ~500KB of WASM space, so im looking into alternative options. Here is what I see as options Spread out the actor classes to other canister(s) Deploy actor classes from dfx (This might have an issue of not being deployable via a DAO) ? Any help or suggestions would be appreciated

But still interested in the original question about how to figure this out easier

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [December 4, 2023, 8:30pm UTC](https://forum.dfinity.org/t/motoko-wasm-size-diagnosing-tips/25268/4 "2023-12-04T20:30:57Z")

</div>

Replace your actor references with actor interfaces unless you are deploying the actor codebase.(And even then you may want to use a factory canister to generate those so you don’t have to import the actor). When you import the actor it puts the compiled wasm into your canister, so you get all the system code in there(possibly multiple times if you have multiple actors).

---

<div class="post-metadata">

**Author:** ![Gekctek](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gekctek/32/6863_2.png) [@Gekctek](https://forum.dfinity.org/u/Gekctek)\
**Post date:** [October 8, 2025, 9:13pm UTC](https://forum.dfinity.org/t/motoko-wasm-size-diagnosing-tips/25268/5 "2025-10-08T21:13:57Z")

</div>

Part 2: [Motoko WASM size diagnosing - Part 2](https://forum.dfinity.org/t/motoko-wasm-size-diagnosing-part-2/58694)
