JFree doesn't work (is just a noop) in unix.

In windows all J memory allocation is done in a J heap and JFree destroys that heap. This is dead simple, almost guaranteed to be complete, and relatively safe.

When the Unix shared library J Engine was added in for 601it wasn't clear how to achieve this in Unix. There didn't seem to be an equivalent service that made it as easy as it was in Windows.

In general (even in Windows) it would probably be better to do the Jinit only once in an application and then use normal J facilities (4!:55 etc) to free J memory as desired.

Apolgies that the lack of documentation on this wasted some of your time.

Adavance warning: JClear doesn't work in either Windows or Unix. JClear uses 4!:56 to erase all J allocations and 4!:56 was removed as there were complications in the implementation.

----- Original Message ----- From: "Yuri Burger" <[EMAIL PROTECTED]>
To: "Programming forum" <[email protected]>
Sent: Friday, December 01, 2006 12:07 PM
Subject: Re: [Jprogramming] embedded J


Source:

#include <stdlib.h>

extern "C"
{
   void* JInit();
   long JFree(void* js);
}

int main(void)
{
   void *j;
   for(int i=0; i<1000000; ++i)
   {
       j=JInit();
       JFree(j);
   }

   return 0;
}

Build script:

g++ -s -O3 main.cpp -lj601


OS: linux, 2.6.x
GCC: 4.0.3


Time/mem_size log:

0 sec        300 MB
3 sec        900 MB
20 sec      1.1 GB
1 min       1.3 GB
2 min        1.5 GB
5 min        crash

Yuri Burger wrote:

It seems that JFree does not freeing anything 8-\  I run a process

which
calls JInit, run several simple sentences and then calls JFree for corresponding J session handle (pointer)... I found that this test has

a
problems with memory leaks.. :(

What is I am doing wrong?


One thing you're not doing is explaining how to reproduce your results, and how a person could tell whether or not they have succeeded in seeing the same results you are getting.

That said, I believe JFree returns memory to the J interpreter, which
is not the same thing as returning memory to the OS. If it's possible to return memory to the OS, without exiting the program, it's probably
only possible in very large chunks (4MB pages, maybe?), and then only
under certain conditions.  [The details will depend on which OS you
are using, and I don't know if or how any of the J interpreters address these issues.]




--
Yuri Burger,
Senior Researcher
Kiev Zoral Development Center

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to