Welcome Guest, Not a member yet? Register   Sign In
ion_auth's 1.2mb memory usage

(This post was last modified: 12-13-2017, 01:39 PM by ponzo.)


I'm a happy user of Ben Edmunds ion_auth.

I was profiling my app, and ion_auth costs 1.2 mb memory on top of my exisiting app, for each pageload
Cant do a better job for the auth part of then ben's ion auth, but i think it's maybe a bit overdone for my application.

4 options to share
a) 1.2 mb isnt a problem at all!
b)  only use this library when a user go's for example to /login , and to check if a user is logged in, make a simple rewrite of
ion_auth->logged_in, so you can skip loading the whole ion_auth library
c) use another auth library below 1.2mb memory usage
d) use an external login API ( i recently only used Instagrams auth api and stored the session in my database)

Best !


I'm not so familiar with your code, but profiling gives me the following result:

I've benchmarked Codeigniter 3.1.6's Welcome controller with the latest ion auth from git.

bare                                         499800 bytes
bare + session library                 522880 bytes
bare + session library + ion_auth 776272 bytes

So for me the difference is 253392 bytes (0.24 MB) with which i can live with.

Also this is on PHP 7.1.11 which has lower memory usage compared to PHP 5.x.x

I've also checked what happens if i just load the ion_auth_model and create a copy of the logged_in() function locally.

The memory usage in that case was:  758864 bytes (0.225 MB), so for me it is not worth it to create a custom lib for this.

PHP Code:
public function loggedin()


$recheck $this->ion_auth_model->recheck_session();

// auto-login the user if they are remembered
if (!$recheck && get_cookie($this->config->item('identity_cookie_name''ion_auth')) && get_cookie($this->config->item('remember_cookie_name''ion_auth')))
$recheck $this->ion_auth_model->login_remembered_user();


(This post was last modified: 12-14-2017, 04:10 AM by ponzo.)

Hi, tested only local on MAMP, php 7.15

Bare install, ion_auth in welcome.php controller and with enable_profiler

1182440 bytes

2557176 bytes

Tested on two different machines (but both Mamp) 

And on production VPS
2 cores / 4.096 MB / CPanel 11.38 + CentOS 6.4

1353664 bytes

With (php 7)
2544984 bytes

With (php 5.6)
3236072 bytes


you must have a bunch of libraries and stuff auto-loaded, right?

(12-14-2017, 02:55 PM)qury Wrote: you must have a bunch of libraries and stuff auto-loaded, right?

Hi Qury,

No, no autoloads, clean install, no other libraries except the ion_auth inside the controller  

Im not an cryptography expert, but the native PHP password hashing API in php > 7.0 
Is enough for safe password hashing (before storing into the database) and verify them when a user is loggin in


Theme © iAndrew 2016 - Forum software by © MyBB