Problem about memory leak error. Would you help me?

 

Hello 


I have a problem.


I don't know why there occurs memory leak.


I made class Ticket.mqh and TicketList.mqh(Vector)


It is made for a convenient order.


The destructor also work properly.


But error of memory leak  occurs.




I'm using two class and some objects (Label)


This below of code is related create and delete.


<List create code>

TicketVector<Ticket> v;


<Ticket create code>

Ticket *t = new Ticket(5,1,0,1);


<Member variable of List>

Ticket *list[];


<Ticket delete code>

delete list[i];
for(int j=i;j<size-1;j++) list[j]=list[j+1];
delete list[size-1];
size--;


<Vector delete code>

delete &v;


Please some body help me ... 


Thank you for sparing your time.

 

Complete code is required to pinpoint the problem - you can prepare a stripped down example.

Apart from this you have an error in "Ticket delete code". You should not delete list[size-1] because you moved it to size-2 in the loop. In other words, when you delete one element, there must be only one delete operator (you have two).

 

It's hard to see what you are doing. As @Stanislav Korotky points out, you need to show all your code.

One tip:

Whenever removing a single (or just a few) item from a list, always use a loop in reverse.