# Memory management

**URL:** <https://discourse.nodered.org/t/memory-management/12072>\
**Category:** General\
**Created:** [11 June 2019 11:48 UTC](https://discourse.nodered.org/t/memory-management/12072 "2019-06-11T11:48:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aargollo](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@aargollo](https://discourse.nodered.org/u/aargollo)\
**Post date:** [11 June 2019 11:48 UTC](https://discourse.nodered.org/t/memory-management/12072/1 "2019-06-11T11:48:16Z")

</div>

Hi Guys, good morning!

I working to finish my Zigbee gateway and I have check an important issue. Some devices, after turn on, sending all those messages necessary and used in the attaching procedure. My parsing code module catches it and including it in the memory, unnecessary because the device already exists in the memory.

**The device object has this structure:**

> Blockquote  
> 11 Jun 11:31:38 - [info] [debug:Parc\_Context Def]  
> { ext\_addr: '00137a000000873b',  
> properties:  
> { nwk\_addr: 'fc0a',  
> nwk\_addrb1: 'fc',  
> nwk\_addrb2: '0a',  
> EP1: '0a',  
> ModelID: 'ZBMLC15',  
> Ext\_addrb1: '00',  
> Ext\_addrb2: '13',  
> Ext\_addrb3: '7a',  
> Ext\_addrb4: '00',  
> Ext\_addrb5: '00',  
> Ext\_addrb6: '00',  
> Ext\_addrb7: '87',  
> Ext\_addrb8: '3b',  
> Type: 'Netvox one circuit actuator' },  
> \_msgid: '5faf619b.9de95' }  
> Blockquote

**I try to check if the device object exists in the memory but I didn't have success:**  
I have used _null or undefined_ to check if exists but is not working.

**Could you see bellow the part of code of my parsing code:**

> Blockquote  
> node.send({  
> "ext\_addr":unique,  
> "properties":properties});  
> var hwid = global.get(unique);

console.log("hwid:",hwid.ext\_addr);

//seting global variable  
if ( **hwid.EP1=== undefined** ){ // doblecheck p/ verificar se o hwid existe  
global.set(unique,  
{"ext\_addr":unique,  
"properties":properties}, "file");  
global.set(unique,  
{"ext\_addr":unique,  
"properties":properties}, "memoryOnly");  
console.log("Device foi registrado");

> Blockquote

**Could you see below the error in the console log:**  
11 Jun 11:31:38 - [error] [function:Context Definiton] TypeError: Cannot read property 'ext\_addr' of undefined

\*\ ***My context data you can see in the pic below that unique doesn't exist in the global variable:**

 ![58](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9e8d33bc77a0a908b0815bfe3dba7130db298e0a.png)

Anybody can help me how to implement it?
