You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by thturk <ta...@hotmail.com> on 2018/10/25 13:32:56 UTC

Release the RAM

I want to release ram when i want ,
i have tired to close created reader, ram directory, and searcher given in
below;

ramDir = new RAMDirectory(FSDirectory.open(indexDir), IOContext.READ);
reader = DirectoryReader.open(ramDir);
searcher = new IndexSearcher(reader);

searcher = null;
reader.close();
reader = null;
ramDir.close();
ramDir = null;

but it didnt  released Ram ,and when i wantto initialize app via tomcat its
loaded all memory then write to disk which i dont want to have 

Is there anyone know what is the best way for this .
Thanks for your help.



--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Release the RAM

Posted by Erick Erickson <er...@gmail.com>.
This really seems like an XY problem. What are you trying to
accomplish that makes you want to use RAMDirectory at all? Why I'm
asking:

1> RAMDirectory is quite special-purpose, very rarely is it something
you should use

2> Java doesn't collect garbage when you close an object that
references it, it'll be collected on some later GC cycle. You can
attach something like jconsole and hit the "force GC" button to see if
the memory is released.

3> bq. "when i want to initialize app via tomcat its loaded all memory
then write to disk which i dont want to have" Again, what is the
purpose here? What are you trying to accomplish _for the user_? I
frankly have no idea what "loaded all memory then write to disk"
means. Writing to disk doesn't happen unless you're updating
documents.

Best,
Erick
On Thu, Oct 25, 2018 at 6:33 AM thturk <ta...@hotmail.com> wrote:
>
> I want to release ram when i want ,
> i have tired to close created reader, ram directory, and searcher given in
> below;
>
> ramDir = new RAMDirectory(FSDirectory.open(indexDir), IOContext.READ);
> reader = DirectoryReader.open(ramDir);
> searcher = new IndexSearcher(reader);
>
> searcher = null;
> reader.close();
> reader = null;
> ramDir.close();
> ramDir = null;
>
> but it didnt  released Ram ,and when i wantto initialize app via tomcat its
> loaded all memory then write to disk which i dont want to have
>
> Is there anyone know what is the best way for this .
> Thanks for your help.
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org