# Code compiled with PackageCompiler allocates more

**URL:** https://discourse.julialang.org/t/code-compiled-with-packagecompiler-allocates-more/112470
**Category:** Performance
**Created:** [April 3, 2024, 12:55pm UTC](https://discourse.julialang.org/t/code-compiled-with-packagecompiler-allocates-more/112470 "2024-04-03T12:55:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Kruxigt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kruxigt/32/11694_2.png) [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)
#### Post date: [April 3, 2024, 12:55pm UTC](https://discourse.julialang.org/t/code-compiled-with-packagecompiler-allocates-more/112470/1 "2024-04-03T12:55:46Z")

</div>

If I compile some code with PackageCompiler and then run

```julia
julia> v = [1,2,3,4];
julia> q = view(v,1:2);
julia> @time collect(q);
  0.000108 seconds (33 allocations: 1008 bytes)

```

while if I do the same in the standard Julia REPL I get:

```julia
julia> v = [1,2,3,4];
julia> q = view(v,1:2);
julia> @time collect(q);
  0.000015 seconds (1 allocation: 80 bytes)

```

The same discrepancies seem to affect other similar cases. This easy one is provided for MRE.

PackageCompiler was run with the arguments:

`Cmd(["--strip-ir", "--compile=all", "--strip-metadata","--cpu-target=generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)"])`

PackageCompiler v2.1.17  
Julia v1.10.0  
MacOS 14.3.1
