# How to clear Javascript Memory Cache



## PankajVerma

Hi All,
I am taking an Array in javascript to store image paths, and at runtime i use that image's height, width and resize it for displaying it as a thumbnail.
But when i update some images, it dont take height & width of updated image, even it shows new image but in old image's size. I am fade up with this problem, plz help me guys.
Regards,
- Pankaj


----------



## ricer333

If you could post some code and maybe a little bit more about the problem (comments about what the behavior is) I'm sure someone here can help you.


----------



## PankajVerma

Hi,

first i have created an array in javascript:

-------------------------
var Pic = new Array();
Pic[1] = 'imgLg/1.jpg';
Caption[1] = '1.jpg';
Pic[2] = 'imgLg/2.jpg';
Caption[2] = '2.jpg';
Pic[3] = 'imgLg/3.jpg';
Caption[3] = '3.jpg';
-------------------------


calling function
-------------------------
Reset_WidthHeight(Pic[1]);
-------------------------


and in my function taking the width & height of image
-------------------------
function Reset_WidthHeight(objImg)
{
var ImgHeight = objImg.height;
var ImgWidth = objImg.width;
}
-------------------------

even i change the order of some of the images, it displays new image with old size.


----------



## ricer333

What if you were to try resetting the heights in your 'reset' function?

Something like:

var ImgHeight = 0;
var ImgWidth = 0;

ImgHeight = objImage.height;
ImgWidth = objImage.width;

** Maybe even printing out in a text field or something the values that ImgHeight and ImgWidth are at the two points in execution??? **


----------



## ricer333

I also don't see where you are returning the image height/width values.

Try posting all the code. That way I can really see what's going on.


----------



## PankajVerma

actually i have to display the image somewhere in my HTML page.
But the display area's height & width are fixed.

so what i did, i tried to *get the actual height & width* of my image and then in code i m checking the its height & width.

suppose fixed height = 100 & width = 100.

my images height = 200 & width = 300.

in this condition i set the images's width = 100
and height = (100/300) * 200.

and by doing this my image wont be discarded.

But the main problem is that, when in my image array i change the order of image like:

instead of -

Pic[1] = 'imgLg/1.jpg';
Pic[2] = 'imgLg/2.jpg';


make it -
Pic[1] = 'imgLg/*2*.jpg';
Pic[2] = 'imgLg/*1*.jpg';

then it again takes the height & width of last image.


----------



## ricer333

Panka,
I'm still very unclear about your problem. Posting little tid bits of code here and there, isn't going to help 'clearify' it for me. It seems as tho there might be a way that you are referencing these images within the array that may be hanging you up. But I'm still uncertain.

Please, do a copy and paste of all your code into the code segment. Give comments as you see fit, maybe even an example. The more information the better!

Sorry, until I can trace through a code block, I cannot help.


----------

