Q: Ejabberd custom module memory leak I'm not well experienced in erlang but need to resolve some task.
We are using Ejabberd for messaging and we want to send push notification to user mobile device when user is offline. For DB we are using MySQL. 
Because user can have more devices and it is common case that user is online on one device but offline on second. We want that on second device he receive the push notification. We have our own push server and calling his push API from Ejabberd
I created new module which process IQ of type urn:xmpp:gcm:0 where the app is sending his push token. And I write into DB table user, resource, token and user status (online/offline)
when user session is closed I update for that resource status to offline.
I added hook on event "user_send_packet" and I load from DB all offline resources from destination users and send push notification to them.
I crated modules mod_notification.erl - for message parsing and handling
and module mod_notification_sql.erl - for SQL queries and updates handling
this are the hooks implemented in module
  gen_iq_handler:add_iq_handler(ejabberd_sm, Host, <<?NS_GCM>>, ?MODULE, iq, no_queue),
  ejabberd_hooks:add(user_send_packet, Host, ?MODULE, user_send_packet, 500),
  ejabberd_hooks:add(sm_register_connection_hook, Host, ?MODULE, user_online, 100),
  ejabberd_hooks:add(sm_remove_connection_hook, Host, ?MODULE, user_offline, 100),

This module is causing memory leak but I can't the cause.
The communication with database is done very similar to "mod_mam_sql" basically just different queries and variables.
I can post the complete code but for start If someone can tell me what can be the possible reasons for memory leak. Because I'm not using some caching or some direct memory allocation. 
update: The IQ processing is making the leak, when I comment the iq handler initialization leak is gone. Is there any rules what should be done or not in iq handler?
Thanks in Advance,
Laslo
